XML API - pdx:addImage
- addBackgroundImage
- addFooter
- addHeader
- addLineNumbering
- addMacroFromDoc
- addPageBorders
- addProperties
- addSection
- createCharacterStyle
- createListStyle
- createParagraphStyle
- docxSettings
- importHeadersAndFooters
- importListStyle
- importStyles
- modifyPageLayout
- parseStyles
- removeFooters
- removeHeaders
- setBackgroundColor
- setDefaultFont
- setDocumentDefaultStyles
- setEncodeUTF8
- setLanguage
- setMarkAsFinal
- addBookmark
- addBreak
- addChart
- addComment
- addCrossReference
- addDateAndHour
- addEndnote
- addExternalFile
- addFootnote
- addFormElement
- addHeading
- addImage
- addLink
- addList
- addMathEquation
- addMergeField
- addOnlineVideo
- addPageNumber
- addShape
- addSimpleField
- addStructuredDocumentTag
- addTable
- addTableContents
- addTableFigures
- addText
- addTextBox
- addWordML
- embedHTML
- clearBlocks
- deleteBlock
- modifyInputFields
- processTemplate
- rawSearchAndReplace
- removeTemplateVariable
- replaceListVariable
- replacePlaceholderImage
- replaceTableVariable
- replaceVariableByExternalFile
- replaceVariableByHtml
- replaceVariableByText
- replaceVariableByWordFragment
- replaceVariableByWordML
- setTemplateSymbol
- setTemplateBlockSymbol
pdx:addImage
Inserts an image into the Word document.
Note
You are reading the XML API documentation. For the PHP API method please go to addImage.
Description
Element definition
You may use this element to insert images (jpg, gif or png) into your Word document.
You may easily control:
- the embedding and positioning of the image within a complex paragraph.
- the size (if not explicitely given, phpdocx tries to read the width and height from the image headers).
- the dpi or dots per inch (by default they are taken from the image headers or set to 96 dpi).
- the scale (default 100%).
- the target: main document (default), headers or footers.
If one wishes to insert an image within a complex paragraph or a table one should use this element in combination with the addText or the addTable element.
Attributes and sub-elements
options
Key | Description |
---|---|
src | Path to the image that you want to insert into the Word document. |
borderColor | Hexadecimal color: FF0000. |
borderStyle | Possible values are:
|
borderWidth | Given in emus (1cm = 360000 emus). |
dpi | Dots per inch. |
float | (left, right, center) floating image. It only applies if textWrap is not inline (default value). |
height | Image height in pixels. |
horizontalOffset | Given in emus (1cm = 360000 emus). Only applies if there is the image is not floating. |
hyperlink | Image link. |
imageAlign | Image aligment: right, center... |
imageCaption | Image caption options |
relativeToHorizontal | margin (default), page, column, character, leftMargin, rightMargin, insideMargin, outsideMargin. Not compatible with inline text wrapping. |
relativeToVertical | margin, page, line (default), paragraph, topMargin, bottomMargin, insideMargin, outsideMargin. Not compatible with inline text wrapping. |
scaling | % of size: 50, 100. |
spacingTop | Spacing top in pixels. |
spacingBottom | Spacing bottom in pixels. |
spacingLeft | Spacing left in pixels. |
spacingRight | Spacing right in pixels. |
target | document (default value), defaultHeader, firstHeader, evenHeader, defaultFooter, firstFooter, evenFooter, comment, endnote or footnote. One should use this parameter in conjunction with the "rawWordML" option to later insert the image in a header or footer. |
textWrap | Text wrap:
|
verticalOffset | Given in emus (1cm = 360000 emus). |
width | Image width in pixels. |