Foxit PDF SDK
com.foxit.sdk.addon.conversion.Convert Class Reference
Inheritance diagram for com.foxit.sdk.addon.conversion.Convert:
com.foxit.sdk.common.Base

Public Member Functions

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

Static Public Member Functions

static boolean fromDWG (String engine_path, String src_dwg_path, String saved_pdf_path, DWG2PDFSettingData settings) throws com.foxit.sdk.PDFException
 Convert a DWG format file to a PDF file. More...
 
static void fromExcel (String src_excel_file_path, String src_file_password, String saved_pdf_path, String engine_path, Excel2PDFSettingData setting_data, String fx_engine_path, String specified_user_profile_path) throws com.foxit.sdk.PDFException
 Convert an Excel format file to a PDF file. More...
 
static void fromHTML (String src_html, String engine_path, String cookies_path, HTML2PDFSettingData setting_data, String saved_pdf_path, int timeout) throws com.foxit.sdk.PDFException
 Convert a HTML format file or a URL of a Web page to a PDF file. More...
 
static void fromHTML (String src_html, String engine_path, FileReaderCallback cookies_reader, HTML2PDFSettingData setting_data, String saved_pdf_path, int timeout) throws com.foxit.sdk.PDFException
 Convert a HTML format file or a URL of a Web page to a PDF file. More...
 
static void fromHTML (String src_html, String engine_path, FileReaderCallback cookies_reader, HTML2PDFSettingData setting_data, FileWriterCallback saved_pdf_filestream, int timeout) throws com.foxit.sdk.PDFException
 Convert a HTML format file or a URL of a Web page to a PDF file. More...
 
static void fromHTML (FileReaderCallback src_html, HTML2PDFRelatedResourceArray html2pdf_related_resource_array, String engine_path, FileReaderCallback cookies_reader, HTML2PDFSettingData setting_data, FileWriterCallback saved_pdf_filestream, int timeout) throws com.foxit.sdk.PDFException
 Convert a HTML format file or a URL of a Web page to a PDF file. More...
 
static void fromImage (String src_img, String saved_pdf_path) throws com.foxit.sdk.PDFException
 Convert a Image format file to a PDF file. More...
 
static void fromImage (FileReaderCallback file_reader, FileWriterCallback saved_pdf_filestream) throws com.foxit.sdk.PDFException
 Convert a Image format file to a PDF file. More...
 
static boolean fromOFD (String src_ofd_path, String password, String saved_pdf_file_path, OFDConvertParam convert_param) throws com.foxit.sdk.PDFException
 Convert OFD file to PDF file. More...
 
static void fromPowerPoint (String src_ppt_file_path, String src_file_password, String saved_pdf_path, String engine_path, PowerPoint2PDFSettingData setting_data, String fx_engine_path, String specified_user_profile_path) throws com.foxit.sdk.PDFException
 Convert a PowerPoint format file to a PDF file. More...
 
static void fromTXT (String src_txt, String saved_pdf_path, TXT2PDFSettingData setting_data) throws com.foxit.sdk.PDFException
 Convert a TXT format file to a PDF file. More...
 
static void fromWord (String src_word_file_path, String src_file_password, String saved_pdf_path, String engine_path, Word2PDFSettingData setting_data, String fx_engine_path, String specified_user_profile_path) throws com.foxit.sdk.PDFException
 Convert a Word format file to a PDF file. More...
 
static boolean toOFD (String src_pdf_path, String password, String saved_ofd_file_path, OFDConvertParam convert_param) throws com.foxit.sdk.PDFException
 Convert PDF file to OFD file. More...
 
static boolean toXML (String src_pdf_path, String src_file_password, String saved_xml_path, String saved_image_folder_path, boolean is_force_to_tagged_pdf) throws com.foxit.sdk.PDFException
 Convert a PDF file to a XML format file. More...
 

Detailed Description

Conversion add-on module can be used to do some conversion between PDF file and other file formats. Before using "Conversion" module, user should first prepare font resource folder as described in "Foxit PDF SDK Developer Guide.pdf" document. Before using any class or methods in this module, please ensure Foxit PDF SDK has been initialized successfully by function common.Library.initialize with a key including "Conversion" module. Before using function Convert.fromDWG , please ensure Foxit PDF SDK has been initialized successfully by function common.Library.initialize with a key including "DWG2PDF" module.

See also
com.foxit.sdk.common.Library

Member Function Documentation

◆ delete()

synchronized void com.foxit.sdk.addon.conversion.Convert.delete ( )

Clean up related resources immediately.

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

◆ fromDWG()

static boolean com.foxit.sdk.addon.conversion.Convert.fromDWG ( String  engine_path,
String  src_dwg_path,
String  saved_pdf_path,
DWG2PDFSettingData  settings 
) throws com.foxit.sdk.PDFException
static

Convert a DWG format file to a PDF file.

Currently, this function can only be used for desktop platforms; for other platform, this function will return false directly without doing anything.

Parameters
[in]engine_pathThe directory path of "DWG to PDF" engine. This should not be an empty string.
[in]src_dwg_pathA DWG or DXF format file path. This should not be an empty string.
[in]saved_pdf_pathA path for saving the converted PDF file. This should not be an empty string.
[in]settingsThe DWG2PDFSettingData object used for converting.
Returns
None.

◆ fromExcel()

static void com.foxit.sdk.addon.conversion.Convert.fromExcel ( String  src_excel_file_path,
String  src_file_password,
String  saved_pdf_path,
String  engine_path,
Excel2PDFSettingData  setting_data,
String  fx_engine_path,
String  specified_user_profile_path 
) throws com.foxit.sdk.PDFException
static

Convert an Excel format file to a PDF file.

Currently, this function can be used for Linux armv8 or Linux desktop system. If you are on a Linux armv8 system, then please ensure that WPS professional is installed on the machine. If you are on a Linux desktop system, then please ensure that LibreOffice is installed on the machine.

Parameters
[in]src_excel_file_pathPath of a Excel format file. This should not be an empty string.
[in]src_file_passwordPassword for the input Excel format file. If no password is needed for the file, please pass an empty string.
[in]saved_pdf_pathPath of the saved PDF file as conversion result. This should not be an empty string.
[in]engine_pathIn linux armv8 system, it is used to represent the path of WPS engine(librpcetapi.so). For examples, "/opt/kingsoft /wps-office/office6". It can be empty. Default path: "/opt/kingsoft/wps-office/office6". In linux desktop system, it is used to represent the path of LibreOffice engine(soffice.bin), and it can not be empty. For examples, "/usr/lib/libreoffice/program".
[in]setting_data(Reserved, unsupported yet)Setting data used for converting.
[in]fx_engine_pathThe path of "Office to PDF" engine. This parameter is applicable only to Linux desktop systems. It can be empty. If the parameter is empty, LibreOffice engine will be called directly for Excel to PDF conversion, otherwise LibreOffice engine will be called through the "Office to PDF" engine for Excel to PDF conversion.
[in]specified_user_profile_pathThe User-defined directory path to store the user profile of the LibreOffice engine. It needs to be used with "Office to PDF" engine. It can be empty. If the parameter is empty, the LibreOffice engine will use the default user profile and does not suppot multi-threading, otherwise LibreOffice engine will create a new user profile in the User-defined directory to support multi-threading.
Returns
None.

◆ fromHTML() [1/4]

static void com.foxit.sdk.addon.conversion.Convert.fromHTML ( String  src_html,
String  engine_path,
String  cookies_path,
HTML2PDFSettingData  setting_data,
String  saved_pdf_path,
int  timeout 
) throws com.foxit.sdk.PDFException
static

Convert a HTML format file or a URL of a Web page to a PDF file.

Currently, this function can only be used for desktop platforms; for other platform, this function will return directly without doing anything.

Parameters
[in]src_htmlA URL of Web page or a HTML format file path. This should not be an empty string.
[in]engine_pathThe directory path of "HTML to PDF" engine. This should not be an empty string.
[in]cookies_pathPath of cookies file. If this is an empty string, that means no cookie file is used. Data format is strongly recommended to use JSON format.
[in]setting_dataSetting data used for converting.
[in]saved_pdf_pathA path for saving the converted PDF file. This should not be an empty string.
[in]timeoutSeconds for timeout used for loading web pages. It should be set to a value greater than 15. If this is less than 15, 15 will be used by default.
Returns
None.

◆ fromHTML() [2/4]

static void com.foxit.sdk.addon.conversion.Convert.fromHTML ( String  src_html,
String  engine_path,
FileReaderCallback  cookies_reader,
HTML2PDFSettingData  setting_data,
String  saved_pdf_path,
int  timeout 
) throws com.foxit.sdk.PDFException
static

Convert a HTML format file or a URL of a Web page to a PDF file.

Currently, this function can only be used for desktop platforms; for other platform, this function will return directly without doing anything.

Parameters
[in]src_htmlA URL of Web page or a HTML format file path. This should not be an empty string.
[in]engine_pathThe directory path of "HTML to PDF" engine. This should not be an empty string.
[in]cookies_readerA com.foxit.sdk.common.fxcrt.FileReaderCallback object which is implemented by user to pass cookies data to Foxit PDF SDK. If this is null, that means no cookie data is used. Data format is strongly recommended to use JSON format.
[in]setting_dataSetting data used for converting.
[in]saved_pdf_pathA path for saving the converted PDF file. This should not be an empty string.
[in]timeoutSeconds for timeout used for loading web pages. It should be set to a value greater than 15. If this is less than 15, 15 will be used by default.
Returns
None.

◆ fromHTML() [3/4]

static void com.foxit.sdk.addon.conversion.Convert.fromHTML ( String  src_html,
String  engine_path,
FileReaderCallback  cookies_reader,
HTML2PDFSettingData  setting_data,
FileWriterCallback  saved_pdf_filestream,
int  timeout 
) throws com.foxit.sdk.PDFException
static

Convert a HTML format file or a URL of a Web page to a PDF file.

Currently, this function can only be used for desktop platforms; for other platform, this function will return directly without doing anything.

Parameters
[in]src_htmlA URL of Web page or a HTML format file path. This should not be an empty string.
[in]engine_pathThe directory path of "HTML to PDF" engine. This should not be an empty string.
[in]cookies_readerA com.foxit.sdk.common.fxcrt.FileReaderCallback object which is implemented by user to pass cookies data to Foxit PDF SDK. If this is null, that means no cookie data is used. Data format is strongly recommended to use JSON format.
[in]setting_dataSetting data used for converting.
[in]saved_pdf_filestreamA com.foxit.sdk.common.fxcrt.FileWriterCallback object for saving the converted PDF file. This should not be null.
[in]timeoutSeconds for timeout used for loading web pages. It should be set to a value greater than 15. If this is less than 15, 15 will be used by default.
Returns
None.

◆ fromHTML() [4/4]

static void com.foxit.sdk.addon.conversion.Convert.fromHTML ( FileReaderCallback  src_html,
HTML2PDFRelatedResourceArray  html2pdf_related_resource_array,
String  engine_path,
FileReaderCallback  cookies_reader,
HTML2PDFSettingData  setting_data,
FileWriterCallback  saved_pdf_filestream,
int  timeout 
) throws com.foxit.sdk.PDFException
static

Convert a HTML format file or a URL of a Web page to a PDF file.

Currently, this function can only be used for desktop platforms and mac arm platforms; for other platform, this function will return directly without doing anything.

Parameters
[in]src_htmlA com.foxit.sdk.common.fxcrt.FileReaderCallback object which is implemented by user to pass html data to Foxit PDF SDK. It must be vaild.
[in]html2pdf_related_resource_arrayThe HTML2PDFRelatedResourceArray which is related to source HTML.
[in]engine_pathThe directory path of "HTML to PDF" engine. This should not be an empty string.
[in]cookies_reader(Reserved;Not supported yet)A com.foxit.sdk.common.fxcrt.FileReaderCallback object which is implemented by user to pass cookies data to Foxit PDF SDK. If this is null, that means no cookie data is used. Data format is strongly recommended to use JSON format.
[in]setting_dataSetting data used for converting.
[in]saved_pdf_filestreamA com.foxit.sdk.common.fxcrt.FileWriterCallback object for saving the converted PDF file. This should not be null.
[in]timeoutSeconds for timeout used for loading web pages. It should be set to a value greater than 15. If this is less than 15, 15 will be used by default.
Returns
None.

◆ fromImage() [1/2]

static void com.foxit.sdk.addon.conversion.Convert.fromImage ( String  src_img,
String  saved_pdf_path 
) throws com.foxit.sdk.PDFException
static

Convert a Image format file to a PDF file.

Parameters
[in]src_imgA image format file path. This should not be an empty string.
[in]saved_pdf_pathA path for saving the converted PDF file. This should not be an empty string.
Returns
None.

◆ fromImage() [2/2]

static void com.foxit.sdk.addon.conversion.Convert.fromImage ( FileReaderCallback  file_reader,
FileWriterCallback  saved_pdf_filestream 
) throws com.foxit.sdk.PDFException
static

Convert a Image format file to a PDF file.

Parameters
[in]file_readerA com.foxit.sdk.common.fxcrt.FileReaderCallback object which is implemented by user to pass image data to Foxit PDF SDK. It must be valid.
[in]saved_pdf_filestreamA com.foxit.sdk.common.fxcrt.FileWriterCallback object for saving the converted PDF file. This should not be null.
Returns
None.

◆ fromOFD()

static boolean com.foxit.sdk.addon.conversion.Convert.fromOFD ( String  src_ofd_path,
String  password,
String  saved_pdf_file_path,
OFDConvertParam  convert_param 
) throws com.foxit.sdk.PDFException
static

Convert OFD file to PDF file.

Please ensure common.Library.initializeOFDEngine has been called successfully before using this function.

Parameters
[in]src_ofd_pathA full path of an existing OFD file. It should not be an empty string.
[in]passwordPassword for the OFD file. It should be an empty string if the OFD file is not encrypted.
[in]saved_pdf_file_pathA full path for the converted PDF file. It should not be an empty string.
[in]convert_paramA convert parameter object.
Returns
true means success, while false means failure.

◆ fromPowerPoint()

static void com.foxit.sdk.addon.conversion.Convert.fromPowerPoint ( String  src_ppt_file_path,
String  src_file_password,
String  saved_pdf_path,
String  engine_path,
PowerPoint2PDFSettingData  setting_data,
String  fx_engine_path,
String  specified_user_profile_path 
) throws com.foxit.sdk.PDFException
static

Convert a PowerPoint format file to a PDF file.

Currently, this function can be used for Linux armv8 or Linux desktop system. If you are on a Linux armv8 system, then please ensure that WPS professional is installed on the machine. If you are on a Linux desktop system, then please ensure that LibreOffice is installed on the machine.

Parameters
[in]src_ppt_file_pathPath of a PowerPoint format file. This should not be an empty string.
[in]src_file_passwordPassword for the input Excel format file. If no password is needed for the file, please pass an empty string.
[in]saved_pdf_pathPath of the saved PDF file as conversion result. This should not be an empty string.
[in]engine_pathIn linux armv8 system, it is used to represent the path of WPS engine(librpcwppapi.so). For examples, "/opt/kingsoft/wps-office/office6". It can be empty. Default path: "/opt/kingsoft/wps-office/office6". In linux desktop system, it is used to represent the path of LibreOffice engine(soffice.bin), and it can not be empty. For examples, "/usr/lib/libreoffice/program".
[in]setting_data(Reserved, unsupported yet)Setting data used for converting.
[in]fx_engine_pathThe path of "Office to PDF" engine. This parameter is applicable only to Linux desktop systems. It can be empty. If the parameter is empty, LibreOffice engine will be called directly for PowerPoint to PDF conversion, otherwise LibreOffice engine will be called through the "Office to PDF" engine for PowerPoint to PDF conversion.
[in]specified_user_profile_pathThe User-defined directory path to store the user profile of the LibreOffice engine. It needs to be used with "Office to PDF" engine. It can be empty. If the parameter is empty, the LibreOffice engine will use the default user profile and does not suppot multi-threading, otherwise LibreOffice engine will create a new user profile in the User-defined directory to support multi-threading.
Returns
None.

◆ fromTXT()

static void com.foxit.sdk.addon.conversion.Convert.fromTXT ( String  src_txt,
String  saved_pdf_path,
TXT2PDFSettingData  setting_data 
) throws com.foxit.sdk.PDFException
static

Convert a TXT format file to a PDF file.

Parameters
[in]src_txtA TXT format file path. This should not be an empty string.
[in]saved_pdf_pathA path for saving the converted PDF file. This should not be an empty string.
[in]setting_dataSetting data used for converting.
Returns
None.

◆ fromWord()

static void com.foxit.sdk.addon.conversion.Convert.fromWord ( String  src_word_file_path,
String  src_file_password,
String  saved_pdf_path,
String  engine_path,
Word2PDFSettingData  setting_data,
String  fx_engine_path,
String  specified_user_profile_path 
) throws com.foxit.sdk.PDFException
static

Convert a Word format file to a PDF file.

Currently, this function can be used for Linux armv8 or Linux desktop system. If you are on a Linux armv8 system, then please ensure that WPS professional is installed on the machine. If you are on a Linux desktop system, then please ensure that LibreOffice is installed on the machine.

Parameters
[in]src_word_file_pathPath of a Word format file. This should not be an empty string.
[in]src_file_passwordPassword for the input Word format file. If no password is needed for the file, please pass an empty string.
[in]saved_pdf_pathPath of the saved PDF file as conversion result. This should not be an empty string.
[in]engine_pathIn linux armv8 system, it is used to represent the path of WPS engine(librpcwpsapi.so). For examples, "/opt/kingsoft/wps-office/office6". It can be empty. Default path: "/opt/kingsoft/wps-office/office6". In linux desktop system, it is used to represent the path of LibreOffice engine(soffice.bin), and it can not be empty. For examples, "/usr/lib/libreoffice/program".
[in]setting_data(Reserved, unsupported yet)Setting data used for converting.
[in]fx_engine_pathThe path of "Office to PDF" engine. This parameter is applicable only to Linux desktop systems. It can be empty. If the parameter is empty, LibreOffice engine will be called directly for Word to PDF conversion, otherwise LibreOffice engine will be called through the "Office to PDF" engine for Word to PDF conversion.
[in]specified_user_profile_pathThe User-defined directory path to store the user profile of the LibreOffice engine. It needs to be used with "Office to PDF" engine. It can be empty. If the parameter is empty, the LibreOffice engine will use the default user profile and does not suppot multi-threading, otherwise LibreOffice engine will create a new user profile in the User-defined directory to support multi-threading.
Returns
None.

◆ toOFD()

static boolean com.foxit.sdk.addon.conversion.Convert.toOFD ( String  src_pdf_path,
String  password,
String  saved_ofd_file_path,
OFDConvertParam  convert_param 
) throws com.foxit.sdk.PDFException
static

Convert PDF file to OFD file.

Please ensure common.Library.initializeOFDEngine has been called successfully before using this function.

Parameters
[in]src_pdf_pathA full path of an existing PDF file. It should not be an empty string.
[in]passwordPassword for the PDF file. It should be an empty string if the PDF file is not encrypted.
[in]saved_ofd_file_pathA full path for the converted OFD file. It should not be an empty string.
[in]convert_paramA convert parameter object.
Returns
true means success, while false means failure.

◆ toXML()

static boolean com.foxit.sdk.addon.conversion.Convert.toXML ( String  src_pdf_path,
String  src_file_password,
String  saved_xml_path,
String  saved_image_folder_path,
boolean  is_force_to_tagged_pdf 
) throws com.foxit.sdk.PDFException
static

Convert a PDF file to a XML format file.

Parameters
[in]src_pdf_pathPath of a PDF file. This should not be an empty string.
[in]src_file_passwordPassword for the input PDF file. If no password is needed for the file, please pass an empty string.
[in]saved_xml_pathPath of the saved XML format file as conversion result. This should not be an empty string.
[in]saved_image_folder_pathA path to specify a folder where image files will be generated during the converting. If this is an empty string, image files will be generated to a folder named "images" (if not exist, Foxit PDF SDK will generate such folder by default). Folder "images" would be in the same directory with saved XML format file (as parameter saved_xml_path).
[in]is_force_to_tagged_pdf(Only useful when input PDF file is not a tagged PDF file) A boolean value to decide whether input PDF file is allowed to be converted to a tagged PDF when input PDF file is not a tagged PDF:
  • true means input PDF file (which is not tagged PDF yet) will first be converted to a tagged PDF. Then the tagged PDF will be converted to a XML format file.

  • false means not allow to convert input PDF file (which is not tagged PDF yet) to a tagged PDF. In this case, input PDF file will not be converted to XML format file and this function will return false.

Returns
true means success, while false means failure.