Platforms
Frameworks
Languages
Platform Specifics
File format support
The Apryse SDK 9.5 or later can be used to convert SVG 1.1 documents to PDF without any external dependencies.
The Apryse SDK accepts SVG graphics as follows:
See Unsupported SVG Features for restrictions.
SVG graphics specify the width and height in the svg element which defines the mapping of the SVG graphics to the target viewport (e.g. the browser window or some part of a PDF page). Often the size of the viewport is specified in absolute units, e.g.
If the size is specified in pixels (px
) the Apryse SDK uses 1pt=1px. These values are also used to calculate the object box for fitting operations. The svg
element may also contain the viewBox
attribute which specifies a window inside the viewport. You can override the size values specified in the SVG graphics file with the SetForcedWidth()
and SetForcedHeight()
methods of the SVGConvertOptions
class.
Some SVG graphics do not contain absolute size information since width
and height
are missing or contain only relative values such as in the following example:
This is used for SVG graphics which are not intended for standalone use. If no absolute size information is available in the SVG graphics you can specify the desired dimensions via the SetFallbackWidth()
and SetFallbackHeight()
methods of the SVGConvertOptions
class. In the fallback width and height are not set the bounding box of the SVG graphics is calculated automatically. By default the calculated bounding box is moved such that the graphics is located at the original position in the coordinate system (i.e. the box does not necessarily use the origin as corner).
Font selection in SVG is controlled by the following properties:
Only the first three of these properties are relevant for selecting an external font. In order to select a suitable font, the following font names are constructed:
where <font-normweight>
is one of
and <font-normstyle>
is
For example, with the following SVG font specification:
The SDK will search for the font Tahoma,Bold,Italic
. The SDK then tries to load the font names listed above one after the other until the process is successful and a font could be loaded. If all attempts fail, the SDK tries to load the font with the name <font-family>
and simulates the Bold and Italic properties if required.
The font-family property may also contain multiple font family names, e.g.
In this case the SDK tries to load the next font in the list if a particular font family could not be loaded. If some font for a font-family
list could be loaded, the SDK attempts to load the remaining font-families
in the list as fallback fonts for the first loaded font. If the master font already has fallback fonts because it has been loaded earlier, the new fallback fonts will be appended to the list of existing fallback fonts.
The SDK automatically maps the generic SVG font families monospace
, sans-serif
and serif
to the Latin core fonts at the first occurrence of a generic SVG font family. The full list of generic font name mappings is as follows (there are no default mappings for the generic font families cursive
and fantasy
):
Generic font name | PDF core font name |
---|---|
monospace | Courier |
monospace,Bold | Courier-Bold |
monospace,Italic | Courier-Oblique |
monospace,Bold,Italic | Courier-BoldOblique |
sans | Helvetica |
sans,Bold | Helvetica-Bold |
sans,Italic | Helvetica-Oblique |
sans,Bold,Italic | Helvetica-BoldOblique |
sans-serif | Helvetica |
sans-serif,Bold | Helvetica-Bold |
sans-serif,Italic | Helvetica-Oblique |
sans-serif,Bold,Italic | Helvetica-BoldOblique |
serif | Times-Roman |
serif,Bold | Times-Bold |
serif,Italic | Times-Italic |
serif,Bold,Italic | Times-BoldItalic |
If all font loading attempts fail, the SDK attempts to load a default font which was specified via the SetDefaultFontFamily()
method of the SVGConvertOptions
class. By default, the Arial Unicode MS
font is used if available, and Helvetica
otherwise. It is highly recommended to either make the Arial Unicode MS
font available, or to specify another font with a large glyph complement via SetDefaultFontFamily()
.
If a selected font does not contain a required glyph, no text will be visible for that glyph.
The SetFallbackFontFamily()
method of the SVGConvertOptions
class can be used to specify a family of fallback fonts. SVG style attributes will be applied to this font family name, assuming that style variants of the specified font family are actually available.
SVG by default uses the sRGB color space for text and vector graphics. Embedded images in SVG may use other color spaces, though. For example, an embedded or referenced JPEG image may use the CMYK color space with or without an ICC profile.
In addition to sRGB the SDK supports additional color spaces using syntax extensions according to the SVG Color 1.2 draft specification. The following table lists supported SVG color spaces along with syntax examples:
color space | SVG syntax examples | notes |
---|---|---|
sRGB |
| SVG 1.1 default color space |
ICC-based color |
| One, three or four color values must be supplied for Grayscale, RGB or CMYK profiles, respectively. |
CIELab |
| |
CIELch |
| Lightness, chroma and hue (in degrees) are converted to CIELab. |
n-colorant |
| The sRGB fallback color is used. |
SVG syntax requires sRGB fallback colors for all variants. The SDK uses the fallback color in case of syntax errors, missing ICC profiles or if the option SetForceSRGB(true)
was set via the SVGConvertOptions
class.
The ICC-based color specifications apply the specified ICC profile which is searched in the SDK's configured resource search path. ICC profiles are ignored if the option SetHonorIccProfile(false)
was set via the SVGConvertOptions
class.
Device-dependent color spaces are supported with the device-gray
, device-rgb
and device-cmyk
keywords.
The device-nchannel
syntax can be used to specify DeviceN colors, but these specifications are ignored in general and the sRGB fallback color is used.
The color spaces listed above can also be used in SVG gradients. However, PDF requires all stop colors for a gradient to be taken from the same color space. If a gradient uses stop colors from different color spaces the sRGB fallback colors for all stop colors are used.
The SDK processes the image element in SVG and accepts JPEG and PNG images as well as nested SVG graphics. Image data may be embedded in the SVG file or located in an external file.
If an image is not available (e.g. because the referenced external image file is missing), the SDK creates a transparent gray checkerboard pattern.
Unsupported SVG features are ignored. As a result, output is created but some aspects of the graphics may be missing or wrong.
SVG files can contain hyperlinks that can be presented to a user as clickable hyperlinks by an SVG viewer, e.g. in a web browser. Hyperlinks are not imported by the SDK.
SVG graphics may reference external resources such as fonts or images via URLs in the graphics file. The SDK does not support retrieval of remote resources. All external resources referenced by an SVG file must be available locally.
The following SVG elements are not supported and are ignored:
animate
, animateColor
, animateMotion
, animateTransform
, script
, mpath
, set
feBlend
, feColorMatrix
, feComponentTransfer
, feComposite
, feConvolveMatrix
, feDiffuseLighting
, feDisplacementMap
, feDistantLight
, feFlood
, feFuncA
, feFuncB
, feFuncG
, feFuncR
, feGaussianBlur
, feImage
, feMerge
, feMergeNode
, feMorphology
, feOffset
, fePointLight
, feSpecularLighting
, feSpotLight
, feTile
, feTurbulence
, filter
cursor
, foreignObject
, vkern
The following attributes and properties are subject to restrictions:
font-variant
is supported only with the keyword smallcaps
, and only for fonts containing the OpenType feature smcp
.text-decoration
are not supported. The SDK doesn’t draw the decoration elements as areas with separate fill and stroke color, but draws the decorations as lines. The lines are drawn with the fill color if present, otherwise with the stroke color.rotate
for the textPath
element is not supported.unicode-bidi
is honored only for TrueType/OpenType fonts containing the required tables for Bidi text layout.glyph-orientation-vertical
is supported according to SVG 1.1 except the angles 180Ëš and 270Ëš which are not supported.preserveAspectRatio
for the view
element is ignored.overflow
for the svg
element does not support the value visible
if a Form XObject is created, i.e. overflowing content is clipped. This can be avoided by setting SetInline(true)
via the SVGConvertOptions
class, which is the default.The following SVG properties are not supported and are ignored: alignment-baseline
, color-interpolation
, color-interpolation-filters
, color-rendering
, cursor
, dominant-baseline
, enable-background
, filter
, flood-color
, flood-opacity
, glyph-orientation-horizontal
, image-rendering
, lighting-color
, pointer-events
, shape-rendering
, text-rendering
The following attributes of supported SVG elements are not supported and are ignored:
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales