JSON API - addSVG

addSVG

PREMIUM TRIAL / ADVANCED

Inserts an SVG.

Note

You are reading the JSON API documentation. For the PHP API method please go to addSVG.

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.

JSON data
Key Description
svg

Path to the local file or string.

borderColor Hexadecimal color: FF0000.
borderStyle Possible values are:
  • solid
  • dot
  • dash
  • lgDash
  • dashDot
  • lgDashDot
  • lgDashDotDot
  • sysDash
  • sysDot
  • sysDashDot
  • sysDashDotDot
borderWidth Given in emus (1cm = 360000 emus).
caption
  • "bookmarkName" set a custom bookmark name
  • "color" set a custom text color
  • "fontSize" set a custom text size in half-points
  • "keepNext" keep in the same page the current paragraph with next paragraph. Default as false
  • "label" set a custom label (Figure by default)
  • "lineSpacing" set a custom text line spacing
  • "position" set a custom position (below by default, above)
  • "pStyle" set a custom style name applied to the paragraph. This option overwrites the "styleName" option as custom paragraph style
  • "showLabel" show default value Figure
  • "styleName" allow setting a custom style name, useful to generate table of figures based on style names
  • "text" text of the caption
  • "wrapTextInBookmarks" wrap text content between bookmarks. Default as true
descr Custom descr value.
distance
  • "top" EMUs
  • "right" EMUs
  • "bottom" EMUs
  • "left" EMUs

Not available using inline textWrap. Spacing options can be used to set spacings in all cases. Default as 0.

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 the image is not floating.
hyperlink Image link (hyperlink or bookmark).
imageAlign Image alignment: right, center...
mime Forces a mime (image/jpg, image/jpeg, image/png, image/gif, image/bmp, image/webp).
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.
streamMode If true, uses src as stream.
target document (default value), defaultHeader, firstHeader, evenHeader, defaultFooter, firstFooter, evenFooter, comment, endnote or footnote.
textWrap Text wrap:
  • 0 (inline)
  • 1 (square)
  • 2 (front)
  • 3 (back)
  • 4 (top and bottom)
verticalAlign top, center, bottom. To be used with relativeFromVertical.
verticalOffset Given in emus (1cm = 360000 emus).
width Image width in pixels.
Code samples

Example #1

Example #2

Release notes
  • phpdocx 18.0:
    • new action.