Foxit PDF SDK
com.foxit.sdk.addon.vectorgraphics.VectorGraphics Class Reference

Class for inserting vector graphics(SVG, WMF/EMF) into PDF files. More...

Inheritance diagram for com.foxit.sdk.addon.vectorgraphics.VectorGraphics:
com.foxit.sdk.common.Base

Public Member Functions

synchronized void delete ()
 Clean up related C++ resources immediately. More...
 
- Public Member Functions inherited from com.foxit.sdk.common.Base
synchronized void delete ()
 Clean up related C++ resources immediately. More...
 

Static Public Member Functions

static void initialize (String library_path) throws com.foxit.sdk.PDFException
 Initialize the vector graphics module by loading the fxvectorgraphics shared library. More...
 
static void insertSVGToPage (String pdf_path, String svg_path, String out_pdf_path, int page_index, float x, float y, float width, float height, int dpi) throws com.foxit.sdk.PDFException
 Insert an SVG file into a rectangular area on an existing PDF page. More...
 
static void insertSVGToPDF (String pdf_path, String svg_path, String out_pdf_path, int page_index, float page_width_pt, float page_height_pt, int dpi) throws com.foxit.sdk.PDFException
 Insert an SVG file as a new page into PDF document. More...
 
static void insertWMFToPage (String pdf_path, String wmf_path, String out_pdf_path, int page_index, float x, float y, float width, float height, int dpi) throws com.foxit.sdk.PDFException
 Insert a WMF/EMF file into a rectangular area on an existing PDF page. More...
 
static void insertWMFToPDF (String pdf_path, String wmf_path, String out_pdf_path, int page_index, float page_width_pt, float page_height_pt, int dpi) throws com.foxit.sdk.PDFException
 Insert a WMF/EMF file as a new page into PDF document. More...
 
static void release () throws com.foxit.sdk.PDFException
 Release all resources allocated by the vector graphics module. More...
 

Detailed Description

Class for inserting vector graphics(SVG, WMF/EMF) into PDF files.

This class provides methods for inserting SVG vector graphics and WMF/EMF metafiles into PDF document. The target PDF is opened, modified, and saved entirely within the fxvectorgraphics shared library, so the caller never needs to open the document with Foxit PDF SDK itself. The output file preserves the structural characteristics of the input PDF (linearization, cross-reference stream, etc.) automatically.

Before calling any other method in this class, call VectorGraphics.initialize to load the fxvectorgraphics shared library. Call VectorGraphics.release when the module is no longer needed.

Currently, this feature is not supported on the Linux x86/ARM and Mac ARM platform.

Member Function Documentation

◆ delete()

synchronized void com.foxit.sdk.addon.vectorgraphics.VectorGraphics.delete ( )

Clean up related C++ resources immediately.

Returns
None.
Note
Once this function is called, current object cannot be used anymore.

◆ initialize()

static void com.foxit.sdk.addon.vectorgraphics.VectorGraphics.initialize ( String  library_path) throws com.foxit.sdk.PDFException
static

Initialize the vector graphics module by loading the fxvectorgraphics shared library.

During the life-cycle of the "vector graphics" module, this function should be called once before any other function in this class. The library remains loaded until VectorGraphics.release is called.

Parameters
[in]library_pathFull path to the fxsvgwmf2pdf shared library file. This should not be an empty string.
Returns
None.
Note
If module "Conversion" is not defined in the license information which is used in function common.Library.initialize , that means user has no right in using vecotr graphics related functions and this function will throw exception com.foxit.sdk.common.Constants.e_ErrNoConversionModuleRight .

◆ insertSVGToPage()

static void com.foxit.sdk.addon.vectorgraphics.VectorGraphics.insertSVGToPage ( String  pdf_path,
String  svg_path,
String  out_pdf_path,
int  page_index,
float  x,
float  y,
float  width,
float  height,
int  dpi 
) throws com.foxit.sdk.PDFException
static

Insert an SVG file into a rectangular area on an existing PDF page.

The SVG graphic is rendered into the specified rectangle on the given page of the source PDF. The result is written to out_pdf_path. The structural characteristics of the source PDF (linearization, XRef stream, etc.) are preserved automatically.

Parameters
[in]pdf_pathPath of the source PDF file. This should not be an empty string.
[in]svg_pathPath of the SVG file. This should not be an empty string.
[in]out_pdf_pathPath of the output PDF file. This should not be an empty string.
[in]page_indexZero-based index of the page to insert the SVG into. Valid range: from 0 to (page_count-1). page_count is returned by function pdf.PDFDoc.getPageCount .
[in]xX coordinate of the left edge of the target rectangle, in points.
[in]yY coordinate of the bottom edge of the target rectangle, in points.
[in]widthWidth of the target rectangle, in points. Must be greater than 0.
[in]heightHeight of the target rectangle, in points. Must be greater than 0.
[in]dpiRendering resolution in dots per inch. Must be greater than 0.
Returns
None.

◆ insertSVGToPDF()

static void com.foxit.sdk.addon.vectorgraphics.VectorGraphics.insertSVGToPDF ( String  pdf_path,
String  svg_path,
String  out_pdf_path,
int  page_index,
float  page_width_pt,
float  page_height_pt,
int  dpi 
) throws com.foxit.sdk.PDFException
static

Insert an SVG file as a new page into PDF document.

A new page of the specified size is inserted at page_index and the SVG graphic is rendered onto it. The result is written to out_pdf_path.

Parameters
[in]pdf_pathPath of the source PDF file. If this is an empty string or the specified file does not exist, a new PDF document will be created using out_pdf_path.
[in]svg_pathPath of the SVG file. This should not be an empty string.
[in]out_pdf_pathPath of the output PDF file. This should not be an empty string.
[in]page_indexZero-based index of the page to insert the SVG into. If this value is less than 0, the page is inserted at the beginning of the document. If it is greater than or equal to page_count, the page is appended to the end of the document. page_count is returned by function pdf.PDFDoc.getPageCount .
[in]page_width_ptWidth of the new page, in points. Must be greater than 0.
[in]page_height_ptHeight of the new page, in points. Must be greater than 0.
[in]dpiRendering resolution in dots per inch. Must be greater than 0.
Returns
None.

◆ insertWMFToPage()

static void com.foxit.sdk.addon.vectorgraphics.VectorGraphics.insertWMFToPage ( String  pdf_path,
String  wmf_path,
String  out_pdf_path,
int  page_index,
float  x,
float  y,
float  width,
float  height,
int  dpi 
) throws com.foxit.sdk.PDFException
static

Insert a WMF/EMF file into a rectangular area on an existing PDF page.

The WMF/EMF graphic is rendered into the specified rectangle on the given page of the source PDF. The result is written to out_pdf_path. The structural characteristics of the source PDF are preserved automatically.

Parameters
[in]pdf_pathPath of the source PDF file. This should not be an empty string.
[in]wmf_pathPath of the WMF/EMF file. This should not be an empty string.
[in]out_pdf_pathPath of the output PDF file. This should not be an empty string.
[in]page_indexZero-based index of the page to insert the WMF/EMF into. Valid range: from 0 to (page_count-1). page_count is returned by function pdf.PDFDoc.getPageCount .
[in]xX coordinate of the left edge of the target rectangle, in points.
[in]yY coordinate of the bottom edge of the target rectangle, in points.
[in]widthWidth of the target rectangle, in points. Must be greater than 0.
[in]heightHeight of the target rectangle, in points. Must be greater than 0.
[in]dpiRendering resolution in dots per inch. Must be greater than 0.
Returns
None.

◆ insertWMFToPDF()

static void com.foxit.sdk.addon.vectorgraphics.VectorGraphics.insertWMFToPDF ( String  pdf_path,
String  wmf_path,
String  out_pdf_path,
int  page_index,
float  page_width_pt,
float  page_height_pt,
int  dpi 
) throws com.foxit.sdk.PDFException
static

Insert a WMF/EMF file as a new page into PDF document.

A new page of the specified size is inserted at page_index and the WMF/EMF graphic is rendered onto it. The result is written to out_pdf_path.

Parameters
[in]pdf_pathPath of the source PDF file. If this is an empty string or the specified file does not exist, a new PDF document will be created using out_pdf_path.
[in]wmf_pathPath of the WMF/EMF file. This should not be an empty string.
[in]out_pdf_pathPath of the output PDF file. This should not be an empty string.
[in]page_indexZero-based index of the page to insert the SVG into. If this value is less than 0, the page is inserted at the beginning of the document. If it is greater than or equal to page_count, the page is appended to the end of the document. page_count is returned by function pdf.PDFDoc.getPageCount .
[in]page_width_ptWidth of the new page, in points. Must be greater than 0.
[in]page_height_ptHeight of the new page, in points. Must be greater than 0.
[in]dpiRendering resolution in dots per inch. Must be greater than 0.
Returns
None.

◆ release()

static void com.foxit.sdk.addon.vectorgraphics.VectorGraphics.release ( ) throws com.foxit.sdk.PDFException
static

Release all resources allocated by the vector graphics module.

When the user no longer needs the "vector graphics" module, this function should be called to unload the shared library and release all associated resources.

Returns
None.