public final class SvgConverter extends Object
| Modifier and Type | Method and Description |
|---|---|
static Image |
convertToImage(InputStream stream,
com.itextpdf.kernel.pdf.PdfDocument document)
Converts a String containing valid SVG content to an
XObject that can then be used on the passed
PdfDocument. |
static Image |
convertToImage(InputStream stream,
com.itextpdf.kernel.pdf.PdfDocument document,
ISvgConverterProperties props)
Converts a String containing valid SVG content to an
image that can then be used on the passed
PdfDocument. |
static com.itextpdf.kernel.pdf.xobject.PdfFormXObject |
convertToXObject(InputStream stream,
com.itextpdf.kernel.pdf.PdfDocument document)
Converts a String containing valid SVG content to an
XObject that can then be used on the passed
PdfDocument. |
static com.itextpdf.kernel.pdf.xobject.PdfFormXObject |
convertToXObject(InputStream stream,
com.itextpdf.kernel.pdf.PdfDocument document,
ISvgConverterProperties props)
Converts a String containing valid SVG content to an
XObject that can then be used on the passed
PdfDocument. |
static com.itextpdf.kernel.pdf.xobject.PdfFormXObject |
convertToXObject(ISvgNodeRenderer topSvgRenderer,
com.itextpdf.kernel.pdf.PdfDocument document)
This method draws a NodeRenderer tree to a canvas that is tied to the
passed document.
|
static com.itextpdf.kernel.pdf.xobject.PdfFormXObject |
convertToXObject(String content,
com.itextpdf.kernel.pdf.PdfDocument document)
Converts a String containing valid SVG content to an
XObject that can then be used on the passed
PdfDocument. |
static com.itextpdf.kernel.pdf.xobject.PdfFormXObject |
convertToXObject(String content,
com.itextpdf.kernel.pdf.PdfDocument document,
ISvgConverterProperties props)
Converts a String containing valid SVG content to an
XObject that can then be used on the passed
PdfDocument. |
static void |
createPdf(File svgFile,
File pdfFile)
|
static void |
createPdf(File svgFile,
File pdfFile,
ISvgConverterProperties props)
|
static void |
createPdf(File svgFile,
File pdfFile,
ISvgConverterProperties props,
com.itextpdf.kernel.pdf.WriterProperties writerProps)
Converts SVG stored in a
File to a PDF File,
using specific ISvgConverterProperties and WriterProperties. |
static void |
createPdf(File svgFile,
File pdfFile,
com.itextpdf.kernel.pdf.WriterProperties writerProps)
|
static void |
createPdf(InputStream svgStream,
OutputStream pdfDest)
Create a single page pdf containing the SVG on its page using the default processing and drawing logic
|
static void |
createPdf(InputStream svgStream,
OutputStream pdfDest,
ISvgConverterProperties props)
Create a single page pdf containing the SVG on its page using the default processing and drawing logic
|
static void |
createPdf(InputStream svgStream,
OutputStream pdfDest,
ISvgConverterProperties props,
com.itextpdf.kernel.pdf.WriterProperties writerProps)
Create a single page pdf containing the SVG on its page using the default processing and drawing logic
|
static void |
createPdf(InputStream svgStream,
OutputStream pdfDest,
com.itextpdf.kernel.pdf.WriterProperties writerprops)
Create a single page pdf containing the SVG on its page using the default processing and drawing logic
|
static void |
drawOnCanvas(InputStream stream,
com.itextpdf.kernel.pdf.canvas.PdfCanvas canvas)
Draws a Stream containing valid SVG to a pre-made canvas object.
|
static void |
drawOnCanvas(InputStream stream,
com.itextpdf.kernel.pdf.canvas.PdfCanvas canvas,
float x,
float y)
Draws a Stream containing valid SVG to a pre-made canvas object, to a specified location.
|
static void |
drawOnCanvas(InputStream stream,
com.itextpdf.kernel.pdf.canvas.PdfCanvas canvas,
float x,
float y,
ISvgConverterProperties props)
Draws a String containing valid SVG to a pre-made canvas object, at a specified position on the canvas.
|
static void |
drawOnCanvas(InputStream stream,
com.itextpdf.kernel.pdf.canvas.PdfCanvas canvas,
ISvgConverterProperties props)
Draws a Stream containing valid SVG to a pre-made canvas object.
|
static void |
drawOnCanvas(String content,
com.itextpdf.kernel.pdf.canvas.PdfCanvas canvas)
Draws a String containing valid SVG to a pre-made canvas object.
|
static void |
drawOnCanvas(String content,
com.itextpdf.kernel.pdf.canvas.PdfCanvas canvas,
float x,
float y)
Draws a String containing valid SVG to a pre-made canvas object.
|
static void |
drawOnCanvas(String content,
com.itextpdf.kernel.pdf.canvas.PdfCanvas canvas,
float x,
float y,
ISvgConverterProperties props)
draws a String containing valid SVG to a pre-made canvas object, at a specified location.
|
static void |
drawOnCanvas(String content,
com.itextpdf.kernel.pdf.canvas.PdfCanvas canvas,
ISvgConverterProperties props)
Draws a String containing valid SVG to a pre-made canvas object.
|
static void |
drawOnDocument(InputStream stream,
com.itextpdf.kernel.pdf.PdfDocument document,
int pageNo)
Draws a Stream containing valid SVG to a document, on a given page
number ate the origni of the page.
|
static void |
drawOnDocument(InputStream stream,
com.itextpdf.kernel.pdf.PdfDocument document,
int pageNo,
float x,
float y)
Draws a Stream containing valid SVG to a document, on a given page
number on the provided x and y coordinate.
|
static void |
drawOnDocument(InputStream stream,
com.itextpdf.kernel.pdf.PdfDocument document,
int pageNo,
float x,
float y,
ISvgConverterProperties props)
Draws a Stream containing valid SVG to a document, on a given page
number on the provided x and y coordinate.
|
static void |
drawOnDocument(InputStream stream,
com.itextpdf.kernel.pdf.PdfDocument document,
int pageNo,
ISvgConverterProperties props)
Draws a Stream containing valid SVG to a document, on a given page
number on the provided x and y coordinate.
|
static void |
drawOnDocument(String content,
com.itextpdf.kernel.pdf.PdfDocument document,
int pageNo)
Draws a String containing valid SVG to a document, on a given page
number at the origin of the page.
|
static void |
drawOnDocument(String content,
com.itextpdf.kernel.pdf.PdfDocument document,
int pageNo,
float x,
float y)
Draws a String containing valid SVG to a document, on a given page
number on the provided x and y coordinate.
|
static void |
drawOnDocument(String content,
com.itextpdf.kernel.pdf.PdfDocument document,
int pageNo,
float x,
float y,
ISvgConverterProperties props)
Draws a String containing valid SVG to a document, on a given page
number on the provided x and y coordinate.
|
static void |
drawOnDocument(String content,
com.itextpdf.kernel.pdf.PdfDocument document,
int pageNo,
ISvgConverterProperties props)
Draws a String containing valid SVG to a document, on a given page
number on the provided x and y coordinate.
|
static void |
drawOnPage(InputStream stream,
com.itextpdf.kernel.pdf.PdfPage page)
Draws a Stream containing valid SVG to a given page at coordinate 0,0.
|
static void |
drawOnPage(InputStream stream,
com.itextpdf.kernel.pdf.PdfPage page,
float x,
float y)
Draws a Stream containing valid SVG to a given page, at a given location.
|
static void |
drawOnPage(InputStream stream,
com.itextpdf.kernel.pdf.PdfPage page,
float x,
float y,
ISvgConverterProperties props)
Draws a Stream containing valid SVG to a given page at a given location.
|
static void |
drawOnPage(InputStream stream,
com.itextpdf.kernel.pdf.PdfPage page,
ISvgConverterProperties props)
Draws a Stream containing valid SVG to a given page at a given location.
|
static void |
drawOnPage(String content,
com.itextpdf.kernel.pdf.PdfPage page)
Draws a String containing valid SVG to a given page at the origin of the page.
|
static void |
drawOnPage(String content,
com.itextpdf.kernel.pdf.PdfPage page,
float x,
float y)
Draws a String containing valid SVG to a given page on the provided x and y coordinate.
|
static void |
drawOnPage(String content,
com.itextpdf.kernel.pdf.PdfPage page,
float x,
float y,
ISvgConverterProperties props)
Draws a String containing valid SVG to a given page on the provided x and y coordinate.
|
static void |
drawOnPage(String content,
com.itextpdf.kernel.pdf.PdfPage page,
ISvgConverterProperties props)
Draws a String containing valid SVG to a given page on the provided x and y coordinate.
|
static float[] |
extractWidthAndHeight(ISvgNodeRenderer topSvgRenderer)
Extract width and height of the passed SVGNodeRenderer,
defaulting to respective viewbox values if either one is not present or
to browser default if viewbox is missing as well
|
static INode |
parse(InputStream stream)
Parse a Stream containing valid SVG into an XML DOM node, using the
default JSoup XML parser.
|
static INode |
parse(InputStream stream,
ISvgConverterProperties props)
Parse a Stream containing valid SVG into an XML DOM node, using the
default JSoup XML parser.
|
static INode |
parse(String content)
Parse a String containing valid SVG into an XML DOM node, using the
default JSoup XML parser.
|
static ISvgProcessorResult |
parseAndProcess(InputStream svgStream)
Parse and process an Inputstream containing an SVG, using the default Svg processor (
DefaultSvgProcessor)
The parsing of the stream is done using UTF-8 as the default charset. |
static ISvgProcessorResult |
parseAndProcess(InputStream svgStream,
ISvgConverterProperties props)
Parse and process an Inputstream containing an SVG, using the default Svg processor (
DefaultSvgProcessor) |
static ISvgProcessorResult |
process(INode root)
Use the default implementation of
ISvgProcessor to convert an XML
DOM tree to a node renderer tree. |
static ISvgProcessorResult |
process(INode root,
ISvgConverterProperties props)
Use the default implementation of
ISvgProcessor to convert an XML
DOM tree to a node renderer tree. |
public static void drawOnDocument(String content, com.itextpdf.kernel.pdf.PdfDocument document, int pageNo)
content - the String value containing valid SVG contentdocument - the PdfDocument instance to draw onpageNo - the page to draw onpublic static void drawOnDocument(String content, com.itextpdf.kernel.pdf.PdfDocument document, int pageNo, float x, float y)
content - the String value containing valid SVG contentdocument - the PdfDocument instance to draw onpageNo - the page to draw onx - x-coordinate of the location to draw aty - y-coordinate of the location to draw atpublic static void drawOnDocument(String content, com.itextpdf.kernel.pdf.PdfDocument document, int pageNo, ISvgConverterProperties props)
content - the Stream object containing valid SVG contentdocument - the PdfDocument instance to draw onpageNo - the page to draw onprops - a container for extra properties that customize the behaviorpublic static void drawOnDocument(String content, com.itextpdf.kernel.pdf.PdfDocument document, int pageNo, float x, float y, ISvgConverterProperties props)
content - the Stream object containing valid SVG contentdocument - the PdfDocument instance to draw onpageNo - the page to draw onx - x-coordinate of the location to draw aty - y-coordinate of the location to draw atprops - a container for extra properties that customize the behaviorpublic static void drawOnDocument(InputStream stream, com.itextpdf.kernel.pdf.PdfDocument document, int pageNo) throws IOException
stream - the Stream object containing valid SVG contentdocument - the PdfDocument instance to draw onpageNo - the page to draw onIOException - when the Stream cannot be read correctlypublic static void drawOnDocument(InputStream stream, com.itextpdf.kernel.pdf.PdfDocument document, int pageNo, float x, float y) throws IOException
stream - the Stream object containing valid SVG contentdocument - the PdfDocument instance to draw onpageNo - the page to draw onx - x-coordinate of the location to draw aty - y-coordinate of the location to draw atIOException - when the Stream cannot be read correctlypublic static void drawOnDocument(InputStream stream, com.itextpdf.kernel.pdf.PdfDocument document, int pageNo, ISvgConverterProperties props) throws IOException
stream - the Stream object containing valid SVG contentdocument - the PdfDocument instance to draw onpageNo - the page to draw onprops - a container for extra properties that customize the behaviorIOException - when the Stream cannot be read correctlypublic static void drawOnDocument(InputStream stream, com.itextpdf.kernel.pdf.PdfDocument document, int pageNo, float x, float y, ISvgConverterProperties props) throws IOException
stream - the Stream object containing valid SVG contentdocument - the PdfDocument instance to draw onpageNo - the page to draw onx - x-coordinate of the location to draw aty - y-coordinate of the location to draw atprops - a container for extra properties that customize the behaviorIOException - when the Stream cannot be read correctlypublic static void drawOnPage(String content, com.itextpdf.kernel.pdf.PdfPage page)
content - the String value containing valid SVG contentpage - the PdfPage instance to draw onpublic static void drawOnPage(String content, com.itextpdf.kernel.pdf.PdfPage page, float x, float y)
content - the String value containing valid SVG contentpage - the PdfPage instance to draw onx - x-coordinate of the location to draw aty - y-coordinate of the location to draw atpublic static void drawOnPage(String content, com.itextpdf.kernel.pdf.PdfPage page, ISvgConverterProperties props)
content - the String value containing valid SVG contentpage - the PdfPage instance to draw onprops - a container for extra properties that customize the behaviorpublic static void drawOnPage(String content, com.itextpdf.kernel.pdf.PdfPage page, float x, float y, ISvgConverterProperties props)
content - the String value containing valid SVG contentpage - the PdfPage instance to draw onx - x-coordinate of the location to draw aty - y-coordinate of the location to draw atprops - a container for extra properties that customize the behaviorpublic static void drawOnPage(InputStream stream, com.itextpdf.kernel.pdf.PdfPage page) throws IOException
stream - the Stream object containing valid SVG contentpage - the PdfPage instance to draw onIOException - when the Stream cannot be read correctlypublic static void drawOnPage(InputStream stream, com.itextpdf.kernel.pdf.PdfPage page, float x, float y) throws IOException
stream - the Stream object containing valid SVG contentpage - the PdfPage instance to draw onx - x-coordinate of the location to draw aty - y-coordinate of the location to draw atIOException - when the Stream cannot be read correctlypublic static void drawOnPage(InputStream stream, com.itextpdf.kernel.pdf.PdfPage page, ISvgConverterProperties props) throws IOException
stream - the Stream object containing valid SVG contentpage - the PdfPage instance to draw onprops - a container for extra properties that customize the behaviorIOException - when the Stream cannot be read correctlypublic static void drawOnPage(InputStream stream, com.itextpdf.kernel.pdf.PdfPage page, float x, float y, ISvgConverterProperties props) throws IOException
stream - the Stream object containing valid SVG contentpage - the PdfPage instance to draw onx - x-coordinate of the location to draw aty - y-coordinate of the location to draw atprops - a container for extra properties that customize the behaviorIOException - when the Stream cannot be read correctlypublic static void drawOnCanvas(String content, com.itextpdf.kernel.pdf.canvas.PdfCanvas canvas)
content - the String value containing valid SVG contentcanvas - the PdfCanvas instance to draw onpublic static void drawOnCanvas(String content, com.itextpdf.kernel.pdf.canvas.PdfCanvas canvas, float x, float y)
content - the String value containing valid SVG contentcanvas - the PdfCanvas instance to draw onx - x-coordinate of the location to draw aty - y-coordinate of the location to draw atpublic static void drawOnCanvas(String content, com.itextpdf.kernel.pdf.canvas.PdfCanvas canvas, ISvgConverterProperties props)
content - the String value containing valid SVG contentcanvas - the PdfCanvas instance to draw onprops - a container for extra properties that customize the behaviorpublic static void drawOnCanvas(String content, com.itextpdf.kernel.pdf.canvas.PdfCanvas canvas, float x, float y, ISvgConverterProperties props)
content - the String value containing valid SVG contentcanvas - the PdfCanvas instance to draw onx - x-coordinate of the location to draw aty - y-coordinate of the location to draw atprops - a container for extra properties that customize the behaviorpublic static void drawOnCanvas(InputStream stream, com.itextpdf.kernel.pdf.canvas.PdfCanvas canvas) throws IOException
stream - the Stream object containing valid SVG contentcanvas - the PdfCanvas instance to draw onIOException - when the Stream cannot be read correctlypublic static void drawOnCanvas(InputStream stream, com.itextpdf.kernel.pdf.canvas.PdfCanvas canvas, float x, float y) throws IOException
stream - the Stream object containing valid SVG contentcanvas - the PdfCanvas instance to draw onx - x-coordinate of the location to draw aty - y-coordinate of the location to draw atIOException - when the Stream cannot be read correctlypublic static void drawOnCanvas(InputStream stream, com.itextpdf.kernel.pdf.canvas.PdfCanvas canvas, ISvgConverterProperties props) throws IOException
stream - the Stream object containing valid SVG contentcanvas - the PdfCanvas instance to draw onprops - a container for extra properties that customize the behaviorIOException - when the Stream cannot be read correctlypublic static void drawOnCanvas(InputStream stream, com.itextpdf.kernel.pdf.canvas.PdfCanvas canvas, float x, float y, ISvgConverterProperties props) throws IOException
stream - the Stream object containing valid SVG contentcanvas - the PdfCanvas instance to draw onx - x-coordinate of the location to draw aty - y-coordinate of the location to draw atprops - a container for extra properties that customize the behaviorIOException - when the Stream cannot be read correctlypublic static void createPdf(File svgFile, File pdfFile) throws IOException
svgFile - the File containing the source SVGpdfFile - the File containing the resulting PDFIOException - Signals that an I/O exception has occurred.public static void createPdf(File svgFile, File pdfFile, ISvgConverterProperties props) throws IOException
svgFile - the File containing the source SVGpdfFile - the File containing the resulting PDFprops - a ISvgConverterProperties instanceIOException - Signals that an I/O exception has occurred.public static void createPdf(File svgFile, File pdfFile, com.itextpdf.kernel.pdf.WriterProperties writerProps) throws IOException
svgFile - the File containing the source SVGpdfFile - the File containing the resulting PDFwriterProps - theWriterProperties for the pdf documentIOException - Signals that an I/O exception has occurred.public static void createPdf(File svgFile, File pdfFile, ISvgConverterProperties props, com.itextpdf.kernel.pdf.WriterProperties writerProps) throws IOException
File to a PDF File,
using specific ISvgConverterProperties and WriterProperties.svgFile - the File containing the source SVGpdfFile - the File containing the resulting PDFprops - a ISvgConverterProperties instancewriterProps - a WriterProperties for the pdf documentIOException - Signals that an I/O exception has occurred.public static void createPdf(InputStream svgStream, OutputStream pdfDest) throws IOException
svgStream - Stream containing the SVGpdfDest - PDF destination outputStreamIOException - when the one of the streams cannot be read correctlypublic static void createPdf(InputStream svgStream, OutputStream pdfDest, com.itextpdf.kernel.pdf.WriterProperties writerprops) throws IOException
svgStream - Stream containing the SVGpdfDest - PDF destination outputStreamwriterprops - writerproperties for the pdf documentIOException - when the one of the streams cannot be read correctlypublic static void createPdf(InputStream svgStream, OutputStream pdfDest, ISvgConverterProperties props) throws IOException
svgStream - Stream containing the SVGpdfDest - PDF destination outputStreamprops - Svg ISvgConverterProperties to change default behaviourIOException - when the one of the streams cannot be read correctlypublic static void createPdf(InputStream svgStream, OutputStream pdfDest, ISvgConverterProperties props, com.itextpdf.kernel.pdf.WriterProperties writerProps) throws IOException
svgStream - Stream containing the SVGprops - ISvgConverterProperties to change default behaviourpdfDest - PDF destination outputStreamwriterProps - WriterProperties for the pdf documentIOException - when the one of the streams cannot be read correctly
public static void createPdf(InputStream svgStream,ISvgConverterProperties props, OutputStream pdfDest) throws IOException {
createPdf(svgStream,props,pdfDest,null);
}
/** Create a single page pdf containing the SVG on its page using the default processing and drawing logic
IOException - when the one of the streams cannot be read correctlypublic static com.itextpdf.kernel.pdf.xobject.PdfFormXObject convertToXObject(String content, com.itextpdf.kernel.pdf.PdfDocument document)
XObject that can then be used on the passed
PdfDocument. This method does NOT manipulate the
PdfDocument in any way.
This method (or its overloads) is the best method to use if you want to
reuse the same SVG image multiple times on the same PdfDocument.
If you want to reuse this object on other PdfDocument instances,
please either use any of the process(com.itextpdf.styledxmlparser.node.INode) overloads in this same
class and convert its result to an XObject with
convertToXObject(ISvgNodeRenderer, PdfDocument) , or look into
using PdfObject.copyTo(PdfDocument).
content - the String value containing valid SVG contentdocument - the PdfDocument instance to draw onXObject containing the PDF instructions
corresponding to the passed SVG contentpublic static com.itextpdf.kernel.pdf.xobject.PdfFormXObject convertToXObject(String content, com.itextpdf.kernel.pdf.PdfDocument document, ISvgConverterProperties props)
XObject that can then be used on the passed
PdfDocument. This method does NOT manipulate the
PdfDocument in any way.
This method (or its overloads) is the best method to use if you want to
reuse the same SVG image multiple times on the same PdfDocument.
If you want to reuse this object on other PdfDocument instances,
please either use any of the process(com.itextpdf.styledxmlparser.node.INode) overloads in this same
class and convert its result to an XObject with
convertToXObject(ISvgNodeRenderer, PdfDocument) , or look into
using PdfObject.copyTo(PdfDocument).
content - the String value containing valid SVG contentdocument - the PdfDocument instance to draw onprops - ISvgConverterProperties to customize the behaviorXObject containing the PDF instructions
corresponding to the passed SVG contentpublic static com.itextpdf.kernel.pdf.xobject.PdfFormXObject convertToXObject(InputStream stream, com.itextpdf.kernel.pdf.PdfDocument document, ISvgConverterProperties props) throws IOException
XObject that can then be used on the passed
PdfDocument. This method does NOT manipulate the
PdfDocument in any way.
This method (or its overloads) is the best method to use if you want to
reuse the same SVG image multiple times on the same PdfDocument.
If you want to reuse this object on other PdfDocument instances,
please either use any of the process(com.itextpdf.styledxmlparser.node.INode) overloads in this same
class and convert its result to an XObject with
convertToXObject(ISvgNodeRenderer, PdfDocument) , or look into
using PdfObject.copyTo(PdfDocument).
stream - the Stream object containing valid SVG contentdocument - the PdfDocument instance to draw onprops - ISvgConverterProperties to customize the behaviorXObject containing the PDF instructions
corresponding to the passed SVG contentIOException - when the Stream cannot be read correctlypublic static com.itextpdf.kernel.pdf.xobject.PdfFormXObject convertToXObject(InputStream stream, com.itextpdf.kernel.pdf.PdfDocument document) throws IOException
XObject that can then be used on the passed
PdfDocument. This method does NOT manipulate the
PdfDocument in any way.
This method (or its overloads) is the best method to use if you want to
reuse the same SVG image multiple times on the same PdfDocument.
If you want to reuse this object on other PdfDocument instances,
please either use any of the process(com.itextpdf.styledxmlparser.node.INode) overloads in this same
class and convert its result to an XObject with
convertToXObject(ISvgNodeRenderer, PdfDocument) , or look into
using PdfObject.copyTo(PdfDocument).
stream - the Stream object containing valid SVG contentdocument - the PdfDocument instance to draw onXObject containing the PDF instructions
corresponding to the passed SVG contentIOException - when the Stream cannot be read correctlypublic static Image convertToImage(InputStream stream, com.itextpdf.kernel.pdf.PdfDocument document) throws IOException
XObject that can then be used on the passed
PdfDocument. This method does NOT manipulate the
PdfDocument in any way.
This method (or its overloads) is the best method to use if you want to
reuse the same SVG image multiple times on the same PdfDocument.
If you want to reuse this object on other PdfDocument instances,
please either use any of the process(com.itextpdf.styledxmlparser.node.INode) overloads in this same
class and convert its result to an XObject with
convertToXObject(ISvgNodeRenderer, PdfDocument) , or look into
using PdfObject.copyTo(PdfDocument).
stream - the Stream object containing valid SVG contentdocument - the PdfDocument instance to draw onImage containing the PDF instructions
corresponding to the passed SVG contentIOException - when the Stream cannot be read correctlypublic static Image convertToImage(InputStream stream, com.itextpdf.kernel.pdf.PdfDocument document, ISvgConverterProperties props) throws IOException
image that can then be used on the passed
PdfDocument. This method does NOT manipulate the
PdfDocument in any way.
This method (or its overloads) is the best method to use if you want to
reuse the same SVG image multiple times on the same PdfDocument.
If you want to reuse this object on other PdfDocument instances,
please either use any of the process(com.itextpdf.styledxmlparser.node.INode) overloads in this same
class and convert its result to an XObject with
convertToXObject(ISvgNodeRenderer, PdfDocument) , or look into
using PdfObject.copyTo(PdfDocument).
stream - the Stream object containing valid SVG contentdocument - the PdfDocument instance to draw onprops - ISvgConverterProperties to customize the behaviorImage containing the PDF instructions
corresponding to the passed SVG contentIOException - when the Stream cannot be read correctlypublic static com.itextpdf.kernel.pdf.xobject.PdfFormXObject convertToXObject(ISvgNodeRenderer topSvgRenderer, com.itextpdf.kernel.pdf.PdfDocument document)
This method (or its overloads) is the best method to use if you want to
reuse the same SVG image multiple times on the same PdfDocument.
If you want to reuse this object on other PdfDocument instances,
please either use any of the process(com.itextpdf.styledxmlparser.node.INode) overloads in this same
class and convert its result to an XObject with
this method, or look into
using PdfObject.copyTo(PdfDocument).
topSvgRenderer - the ISvgNodeRenderer instance that contains
the renderer treedocument - the document that the returned
XObject can be drawn on (on any given page
coordinates)XObjectcontaining the PDF instructions
corresponding to the passed node renderer tree.public static ISvgProcessorResult parseAndProcess(InputStream svgStream) throws IOException
DefaultSvgProcessor)
The parsing of the stream is done using UTF-8 as the default charset.
The properties used by the processor are the SvgConverterPropertiessvgStream - Input stream containing the SVG to parse and processISvgProcessorResult containing the root renderer and metadata of the svgIOException - when the Stream cannot be read correctlypublic static ISvgProcessorResult parseAndProcess(InputStream svgStream, ISvgConverterProperties props) throws IOException
DefaultSvgProcessor)svgStream - Stream containing the SVG to parse and processprops - ISvgConverterProperties used by the processorISvgProcessorResult containing the root renderer and metadata of the svgIOException - when the Stream cannot be read correctlypublic static ISvgProcessorResult process(INode root)
ISvgProcessor to convert an XML
DOM tree to a node renderer tree.root - the XML DOM treepublic static ISvgProcessorResult process(INode root, ISvgConverterProperties props)
ISvgProcessor to convert an XML
DOM tree to a node renderer tree. The passed properties can modify the default behaviourroot - the XML DOM treeprops - ISvgConverterProperties to customize the behaviorpublic static INode parse(String content)
content - the String value containing valid SVG contentpublic static INode parse(InputStream stream) throws IOException
UTF-8.stream - the Stream object containing valid SVG contentIOException - when the Stream cannot be read correctlypublic static INode parse(InputStream stream, ISvgConverterProperties props) throws IOException
UTF-8, unless specified otherwise by the method
ISvgConverterProperties.getCharset() of the props
parameter.stream - the Stream object containing valid SVG contentprops - ISvgConverterProperties to customize the behaviorIOException - when the Stream cannot be read correctlypublic static float[] extractWidthAndHeight(ISvgNodeRenderer topSvgRenderer)
topSvgRenderer - Copyright © 1998–2019 iText Group NV. All rights reserved.