Foxit PDF SDK

Public Types | Static Public Member Functions | List of all members
foxit.addon.conversion.Convert Class Reference
Inheritance diagram for foxit.addon.conversion.Convert:

## Public Types
enum | Office2PdfEngine { Office2PdfEngine.e_Office2PdfEngineMicrosoft = 0, Office2PdfEngine.e_Office2PdfEngineWps = 1 }
| Enumeration for engine type used for office to PDF conversion on Windows platforms. More...

## Static Public Member Functions
static bool | FromDWG (string engine_path, string src_dwg_path, string saved_pdf_path, DWG2PDFSettingData settings)
| 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, Excel2PDFSettingData setting_data, Convert.Office2PdfEngine engine)
| 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)
| 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)
| 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)
| 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)
| 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)
| Convert a Image format file to a PDF file. More...
static void | FromImage (FileReaderCallback file_reader, FileWriterCallback saved_pdf_filestream)
| Convert a Image format file to a PDF file. More...
static bool | FromOFD (string src_ofd_path, string password, string saved_pdf_file_path, OFDConvertParam convert_param)
| Convert OFD file to PDF file. More...
static void | FromPowerPoint (string src_ppt_file_path, string src_file_password, string saved_pdf_path, PowerPoint2PDFSettingData setting_data, Convert.Office2PdfEngine engine)
| Convert a PowerPoint format file to a PDF file. More...
static void | FromTXT (string src_txt, string saved_pdf_path, TXT2PDFSettingData setting_data)
| 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, Word2PDFSettingData setting_data, Convert.Office2PdfEngine engine)
| Convert a Word format file to a PDF file. More...
static bool | ToOFD (string src_pdf_path, string password, string saved_ofd_file_path, OFDConvertParam convert_param)
| Convert PDF file to OFD file. More...
static bool | ToXML (string src_pdf_path, string src_file_password, string saved_xml_path, string saved_image_folder_path, bool is_force_to_tagged_pdf)
| 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 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. From version 11.0, we do not update and maintance HTML2PDF engine package on linux x86 platform and maybe it will be deprecated in the future version on linux x86 platform.

See also
  foxit.common.Library

## Member Enumeration Documentation

## ◆ Office2PdfEngine

enum foxit.addon.conversion.Convert.Office2PdfEngine
| strong

Enumeration for engine type used for office to PDF conversion on Windows platforms.

Values of this enumeration should be used alone.

Enumerator
e_Office2PdfEngineMicrosoft | Microsoft Office automation engine.
e_Office2PdfEngineWps | WPS Office automation engine.

## Member Function Documentation

## ◆ FromDWG()

static bool foxit.addon.conversion.Convert.FromDWG | ( | string | engine_path,
|  | string | src_dwg_path,
|  | string | saved_pdf_path,
|  | DWG2PDFSettingData | settings
| ) |  |
| inline 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_path | The directory path of "DWG to PDF" engine. This should not be an empty string.
  [in] | src_dwg_path | A DWG or DXF format file path. This should not be an empty string.
  [in] | saved_pdf_path | A path for saving the converted PDF file. This should not be an empty string.
  [in] | settings | The DWG2PDFSettingData object used for converting.

Returns
  None.

## ◆ FromExcel()

static void foxit.addon.conversion.Convert.FromExcel | ( | string | src_excel_file_path,
|  | string | src_file_password,
|  | string | saved_pdf_path,
|  | Excel2PDFSettingData | setting_data,
|  | Convert.Office2PdfEngine | engine
| ) |  |
| inline static

Convert an Excel format file to a PDF file.

Currently, this function can only be used for Windows.

Parameters

  [in] | src_excel_file_path | Path of a Excel format file. This should not be an empty string.
  [in] | src_file_password | Password for the input Excel format file. If no password is needed for the file, please pass an empty string.
  [in] | saved_pdf_path | Path of the saved PDF file as conversion result. This should not be an empty string.
  [in] | setting_data | Setting data used for converting.
  [in] | engine | Conversion engine to use. Please refer to values starting from foxit.addon.conversion.Convert.Office2PdfEngine.e_Office2PdfEngineMicrosoft and this should be one of these values. Default value:foxit.addon.conversion.Convert.Office2PdfEngine.e_Office2PdfEngineMicrosoft .

Returns
  None.

## ◆ FromHTML() [1/4]

static void foxit.addon.conversion.Convert.FromHTML | ( | string | src_html,
|  | string | engine_path,
|  | string | cookies_path,
|  | HTML2PDFSettingData | setting_data,
|  | string | saved_pdf_path,
|  | int | timeout
| ) |  |
| inline 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_html | A URL of Web page or a HTML format file path. This should not be an empty string.
  [in] | engine_path | The directory path of "HTML to PDF" engine. This should not be an empty string.
  [in] | cookies_path | Path 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_data | Setting data used for converting.
  [in] | saved_pdf_path | A path for saving the converted PDF file. This should not be an empty string.
  [in] | timeout | Seconds 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 foxit.addon.conversion.Convert.FromHTML | ( | string | src_html,
|  | string | engine_path,
|  | FileReaderCallback | cookies_reader,
|  | HTML2PDFSettingData | setting_data,
|  | string | saved_pdf_path,
|  | int | timeout
| ) |  |
| inline 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_html | A URL of Web page or a HTML format file path. This should not be an empty string.
  [in] | engine_path | The directory path of "HTML to PDF" engine. This should not be an empty string.
  [in] | cookies_reader | A foxit.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_data | Setting data used for converting.
  [in] | saved_pdf_path | A path for saving the converted PDF file. This should not be an empty string.
  [in] | timeout | Seconds 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 foxit.addon.conversion.Convert.FromHTML | ( | string | src_html,
|  | string | engine_path,
|  | FileReaderCallback | cookies_reader,
|  | HTML2PDFSettingData | setting_data,
|  | FileWriterCallback | saved_pdf_filestream,
|  | int | timeout
| ) |  |
| inline 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_html | A URL of Web page or a HTML format file path. This should not be an empty string.
  [in] | engine_path | The directory path of "HTML to PDF" engine. This should not be an empty string.
  [in] | cookies_reader | A foxit.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_data | Setting data used for converting.
  [in] | saved_pdf_filestream | A foxit.common.fxcrt.FileWriterCallback object for saving the converted PDF file. This should not be null.
  [in] | timeout | Seconds 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 foxit.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
| ) |  |
| inline 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_html | A foxit.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_array | The HTML2PDFRelatedResourceArray which is related to source HTML.
  [in] | engine_path | The directory path of "HTML to PDF" engine. This should not be an empty string.
  [in] | cookies_reader | (Reserved;Not supported yet)A foxit.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_data | Setting data used for converting.
  [in] | saved_pdf_filestream | A foxit.common.fxcrt.FileWriterCallback object for saving the converted PDF file. This should not be null.
  [in] | timeout | Seconds 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 foxit.addon.conversion.Convert.FromImage | ( | string | src_img,
|  | string | saved_pdf_path
| ) |  |
| inline static

Convert a Image format file to a PDF file.

Parameters

  [in] | src_img | A image format file path. This should not be an empty string.
  [in] | saved_pdf_path | A path for saving the converted PDF file. This should not be an empty string.

Returns
  None.

## ◆ FromImage() [2/2]

static void foxit.addon.conversion.Convert.FromImage | ( | FileReaderCallback | file_reader,
|  | FileWriterCallback | saved_pdf_filestream
| ) |  |
| inline static

Convert a Image format file to a PDF file.

Parameters

  [in] | file_reader | A foxit.common.fxcrt.FileReaderCallback object which is implemented by user to pass image data to Foxit PDF SDK. It must be valid.
  [in] | saved_pdf_filestream | A foxit.common.fxcrt.FileWriterCallback object for saving the converted PDF file. This should not be null.

Returns
  None.

## ◆ FromOFD()

static bool foxit.addon.conversion.Convert.FromOFD | ( | string | src_ofd_path,
|  | string | password,
|  | string | saved_pdf_file_path,
|  | OFDConvertParam | convert_param
| ) |  |
| inline static

Convert OFD file to PDF file.

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

Parameters

  [in] | src_ofd_path | A full path of an existing OFD file. It should not be an empty string.
  [in] | password | Password for the OFD file. It should be an empty string if the OFD file is not encrypted.
  [in] | saved_pdf_file_path | A full path for the converted PDF file. It should not be an empty string.
  [in] | convert_param | A convert parameter object.

Returns
  true means success, while false means failure.

## ◆ FromPowerPoint()

static void foxit.addon.conversion.Convert.FromPowerPoint | ( | string | src_ppt_file_path,
|  | string | src_file_password,
|  | string | saved_pdf_path,
|  | PowerPoint2PDFSettingData | setting_data,
|  | Convert.Office2PdfEngine | engine
| ) |  |
| inline static

Convert a PowerPoint format file to a PDF file.

Currently, this function can only be used for Windows.

Parameters

  [in] | src_ppt_file_path | Path of a PowerPoint format file. This should not be an empty string.
  [in] | src_file_password | Password for the input Excel format file. If no password is needed for the file, please pass an empty string.
  [in] | saved_pdf_path | Path of the saved PDF file as conversion result. This should not be an empty string.
  [in] | setting_data | Setting data used for converting.
  [in] | engine | Conversion engine to use. Please refer to values starting from foxit.addon.conversion.Convert.Office2PdfEngine.e_Office2PdfEngineMicrosoft and this should be one of these values. Default value:foxit.addon.conversion.Convert.Office2PdfEngine.e_Office2PdfEngineMicrosoft .

Returns
  None.

## ◆ FromTXT()

static void foxit.addon.conversion.Convert.FromTXT | ( | string | src_txt,
|  | string | saved_pdf_path,
|  | TXT2PDFSettingData | setting_data
| ) |  |
| inline static

Convert a TXT format file to a PDF file.

Parameters

  [in] | src_txt | A TXT format file path. This should not be an empty string.
  [in] | saved_pdf_path | A path for saving the converted PDF file. This should not be an empty string.
  [in] | setting_data | Setting data used for converting.

Returns
  None.

## ◆ FromWord()

static void foxit.addon.conversion.Convert.FromWord | ( | string | src_word_file_path,
|  | string | src_file_password,
|  | string | saved_pdf_path,
|  | Word2PDFSettingData | setting_data,
|  | Convert.Office2PdfEngine | engine
| ) |  |
| inline static

Convert a Word format file to a PDF file.

Currently, this function can only be used for Windows.

Parameters

  [in] | src_word_file_path | Path of a Word format file. This should not be an empty string.
  [in] | src_file_password | Password for the input Word format file. If no password is needed for the file, please pass an empty string.
  [in] | saved_pdf_path | Path of the saved PDF file as conversion result. This should not be an empty string.
  [in] | setting_data | Setting data used for converting.
  [in] | engine | Conversion engine to use. Please refer to values starting from foxit.addon.conversion.Convert.Office2PdfEngine.e_Office2PdfEngineMicrosoft and this should be one of these values. Default value:foxit.addon.conversion.Convert.Office2PdfEngine.e_Office2PdfEngineMicrosoft .

Returns
  None.

## ◆ ToOFD()

static bool foxit.addon.conversion.Convert.ToOFD | ( | string | src_pdf_path,
|  | string | password,
|  | string | saved_ofd_file_path,
|  | OFDConvertParam | convert_param
| ) |  |
| inline static

Convert PDF file to OFD file.

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

Parameters

  [in] | src_pdf_path | A full path of an existing PDF file. It should not be an empty string.
  [in] | password | Password for the PDF file. It should be an empty string if the PDF file is not encrypted.
  [in] | saved_ofd_file_path | A full path for the converted OFD file. It should not be an empty string.
  [in] | convert_param | A convert parameter object.

Returns
  true means success, while false means failure.

## ◆ ToXML()

static bool foxit.addon.conversion.Convert.ToXML | ( | string | src_pdf_path,
|  | string | src_file_password,
|  | string | saved_xml_path,
|  | string | saved_image_folder_path,
|  | bool | is_force_to_tagged_pdf
| ) |  |
| inline static

Convert a PDF file to a XML format file.

Parameters

  [in] | src_pdf_path | Path of a PDF file. This should not be an empty string.
  [in] | src_file_password | Password for the input PDF file. If no password is needed for the file, please pass an empty string.
  [in] | saved_xml_path | Path of the saved XML format file as conversion result. This should not be an empty string.
  [in] | saved_image_folder_path | A 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.