addSVG
- addBibliography
- addBookmark
- addBreak
- addChart
- addCitation
- addComment
- addCrossReference
- addDateAndHour
- addEndnote
- addExternalFile
- addFootnote
- addFormElement
- addHeading
- addImage
- addLink
- addList
- addMathEquation
- addMergeField
- addOLE
- addOnlineVideo
- addPageNumber
- addShape
- addSimpleField
- addSource
- addStructuredDocumentTag
- addSVG
- addTab
- addTable
- addTableContents
- addTableFigures
- addText
- addTextBox
- addWordFragment
- addWordML
- embedHTML
- addBackgroundImage
- addFooter
- addFooterSection
- addHeader
- addHeaderSection
- addLineNumbering
- addMacroFromDoc
- addPageBorders
- addProperties
- addSection
- createDocx
- createDocxAndDownload
- createCharacterStyle
- createListStyle
- createParagraphStyle
- createTableStyle
- docxSettings
- embedFont
- importChartStyle
- importHeadersAndFooters
- importListStyle
- importStyles
- importStylesWordDefault
- modifyPageLayout
- parseStyles
- removeFooters
- removeHeaders
- setBackgroundColor
- setDecimalSymbol
- setDefaultFont
- setDocumentDefaultStyles
- setEncodeUTF8
- setLanguage
- setMarkAsFinal
- setRTL
- clearBlocks
- cloneBlock
- deleteBlock
- getTemplateVariables
- getTemplateVariablesType
- modifyInputFields
- modifyMergeFields
- processTemplate
- removeTemplateVariable
- removeTemplateVariableImage
- replaceBlock
- replaceListVariable
- replacePlaceholderImage
- replaceTableVariable
- replaceVariableByExternalFile
- replaceVariableByHtml
- replaceVariableByText
- replaceVariableByWordFragment
- replaceVariableByWordML
- setTemplateSymbol
- setTemplateBlockSymbol
- tickCheckboxes
addSVG
TRIAL / ADVANCED / PREMIUM
Inserts an SVG into the Word document.
Description
public addSVG ( string $svg, [array $options] )
You may use this method to insert an SVG content, as file or string, into your Word document.
To keep compatibility with DOCX readers not compatible with SVG images, a PNG image with the same content is added too in the document.
This method requires the PHP ImageMagick extension installed and enabled.
Parameters
svg
File path or SVG content.
options
The possible keys and values are:
Key | Type | Description |
---|---|---|
borderColor | string | hexadecimal color: FF0000. |
borderStyle | string | Possible values are:
|
borderWidth | int | Given in emus (1cm = 360000 emus). |
caption | array |
|
dpi | int | Dots per inch. |
float | string | (left, right, center) floating image. It only applies if textWrap is not inline (default value). |
height | int | Image height in pixels. |
horizontalOffset | int | Given in emus (1cm = 360000 emus). Only applies if the image is not floating. |
hyperlink | string | Image link. |
imageAlign | string | Image alignment: right, center... |
relativeToHorizontal | string | margin (default), page, column, character, leftMargin, rightMargin, insideMargin, outsideMargin. Not compatible with inline text wrapping. |
relativeToVertical | string | margin, page, line (default), paragraph, topMargin, bottomMargin, insideMargin, outsideMargin. Not compatible with inline text wrapping. |
resolution | array | x, y resolution. |
spacingTop | int | Spacing top in pixels. |
spacingBottom | int | Spacing bottom in pixels. |
spacingLeft | int | Spacing left in pixels. |
spacingRight | int | Spacing right in pixels. |
target | string | document (default value), defaultHeader, firstHeader, evenHeader, defaultFooter, firstFooter, evenFooter, comment, endnote or footnote. |
textWrap | int | Text wrap:
|
verticalAlign | string | top, center, bottom. To be used with relativeFromVertical. |
verticalOffset | int | Given in emus (1cm = 360000 emus). |
width | int | Image width in pixels. |
Exceptions
ImageMagick is not available.
Image error.
Code samples
Release notes
- phpdocx 13.0:
- resolution option.
- phpdocx 12.0:
- new method.