Class: Docxer::Word::Headers::Header::Image
- Inherits:
-
Object
- Object
- Docxer::Word::Headers::Header::Image
- Defined in:
- lib/docxer/word/headers/header.rb
Instance Attribute Summary collapse
-
#media ⇒ Object
Returns the value of attribute media.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #height ⇒ Object
-
#initialize(media, options = {}) ⇒ Image
constructor
A new instance of Image.
- #render(xml) ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(media, options = {}) ⇒ Image
Returns a new instance of Image.
48 49 50 51 52 |
# File 'lib/docxer/word/headers/header.rb', line 48 def initialize(media, ={}) @media = media @media.file.rewind @options = end |
Instance Attribute Details
#media ⇒ Object
Returns the value of attribute media.
47 48 49 |
# File 'lib/docxer/word/headers/header.rb', line 47 def media @media end |
#options ⇒ Object
Returns the value of attribute options.
47 48 49 |
# File 'lib/docxer/word/headers/header.rb', line 47 def @options end |
Instance Method Details
#height ⇒ Object
58 59 60 |
# File 'lib/docxer/word/headers/header.rb', line 58 def height @options[:height] end |
#render(xml) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/docxer/word/headers/header.rb', line 62 def render(xml) xml['w'].p do xml['w'].pPr do xml['w'].jc( 'w:val' => @options[:align] ) if @options[:align] end xml['w'].r do xml['w'].rPr do xml['w'].noProof end xml['w'].drawing do xml['wp'].inline( 'distT' => 0, 'distB' => 0, 'distL' => 0, 'distR' => 0 ) do xml['wp'].extent( 'cx' => ( width * 9250 ).to_i, 'cy' => ( height * 9250 ).to_i ) xml['wp'].effectExtent( 'l' => 0, 't' => 0, 'r' => 0, 'b' => 1905 ) xml['wp'].docPr( 'id' => 1, 'name'=> "Image", 'descr' => "image") xml['wp'].cNvGraphicFramePr do xml.graphicFrameLocks( 'xmlns:a' => "http://schemas.openxmlformats.org/drawingml/2006/main", 'noChangeAspect' => 1 ) do xml.parent.namespace = xml.parent.namespace_definitions.find{|ns| ns.prefix == "a" } end end xml.graphic( 'xmlns:a' => "http://schemas.openxmlformats.org/drawingml/2006/main" ) do xml.parent.namespace = xml.parent.namespace_definitions.find{|ns| ns.prefix == "a" } xml['a'].graphicData( 'uri' => "http://schemas.openxmlformats.org/drawingml/2006/picture") do xml.pic( 'xmlns:pic' => "http://schemas.openxmlformats.org/drawingml/2006/picture" ) do xml.parent.namespace = xml.parent.namespace_definitions.find{|ns| ns.prefix == "pic" } xml['pic'].nvPicPr do xml['pic'].cNvPr( 'id' => 0, 'name' => "Image" ) xml['pic'].cNvPicPr end xml['pic'].blipFill do xml['a'].blip( 'r:embed' => @media.sequence ) do xml['a'].extLst end xml['a'].stretch do xml['a'].fillRect end end xml['pic'].spPr do xml['a'].xfrm do xml['a'].off( 'x' => 0, 'y' => 0 ) xml['a'].ext( 'cx' => ( width * 50 ).to_i, 'cy' => ( height * 50 ).to_i ) end xml['a'].prstGeom( 'prst' => "rect" ) do xml['a'].avLst end end end end end end end end end end |
#width ⇒ Object
54 55 56 |
# File 'lib/docxer/word/headers/header.rb', line 54 def width @options[:width] end |