Class: Convert

PDFNet. Convert


new Convert()

Converter is a utility class used to convert documents and files to PDF. Conversion of XPS, EMF and image files to PDF documents is performed internally. Other document formats are converted via native application and printing.

Classes

CADConvertOptions
EPUBOutputOptions
HTMLOutputOptions
OfficeToPDFOptions
SVGOutputOptions
TiffOutputOptions
XODOutputOptions
XPSOutputCommonOptions
XPSOutputOptions

Members


<static> AnnotationOutputFlag

Properties:
Name Type Description
e_internal_xfdf number include the annotation file in the XOD output. This is the default option
e_external_xfdf number output the annotation file externally to the same output path with extension .xfdf. This is not available when using streaming conversion
e_flatten number flatten all annotations that are not link annotations

<static> FlattenFlag

Properties:
Name Type Description
e_off number Disable flattening and convert all content as is.
e_simple number Feature reduce PDF to a simple two layer representation consisting of a single background RGB image and a simple top text layer.
e_fast number Feature reduce PDF while trying to preserve some complex PDF features (such as vector figures, transparency, shadings, blend modes, Type3 fonts etc.) for pages that are already fast to render. This option can also result in smaller & faster files compared to e_simple, but the pages may have more complex structure.
e_high_quality number Preserve vector content where possible. In particular only feature reduce PDF files containing overprint or very complex vector content. Currently this option can only be used with XODOutputOptions.

<static> FlattenThresholdFlag

Properties:
Name Type Description
e_very_strict number Render (flatten) any text that is clipped or occluded.
e_strict number Render text that are marginally clipped or occluded.
e_default number Render text that are somewhat clipped or occluded.
e_keep_most number Only render text that are seriously clipped or occluded.
e_keep_all number Only render text that are completely occluded, or used as a clipping path.

<static> OverprintPreviewMode

Properties:
Name Type Description
e_op_off number
e_op_on number
e_op_pdfx_on number

<static> PrinterMode

Properties:
Name Type Description
e_auto number
e_interop_only number
e_printer_only number
e_prefer_builtin_converter number

Methods


<static> createCADConvertOptions()

Method to create an CADConvertOptions object
Returns:
A promise that resolves to a PDFNet.Convert.CADConvertOptions.
Type
Promise.<PDFNet.Convert.CADConvertOptions>

<static> createEPUBOutputOptions()

Method to create an EPUBOutputOptions object
Returns:
A promise that resolves to a PDFNet.Convert.EPUBOutputOptions.
Type
Promise.<PDFNet.Convert.EPUBOutputOptions>

<static> createHTMLOutputOptions()

Method to create an HTMLOutputOptions object
Returns:
A promise that resolves to a PDFNet.Convert.HTMLOutputOptions.
Type
Promise.<PDFNet.Convert.HTMLOutputOptions>

<static> createOfficeToPDFOptions()

Method to create an OfficeToPDFOptions object
Returns:
A promise that resolves to a PDFNet.Convert.OfficeToPDFOptions.
Type
Promise.<PDFNet.Convert.OfficeToPDFOptions>

<static> createSVGOutputOptions()

Method to create an SVGOutputOptions object
Returns:
A promise that resolves to a PDFNet.Convert.SVGOutputOptions.
Type
Promise.<PDFNet.Convert.SVGOutputOptions>

<static> createTiffOutputOptions()

Method to create an TiffOutputOptions object
Returns:
A promise that resolves to a PDFNet.Convert.TiffOutputOptions.
Type
Promise.<PDFNet.Convert.TiffOutputOptions>

<static> createXODOutputOptions()

Method to create an XODOutputOptions object
Returns:
A promise that resolves to a PDFNet.Convert.XODOutputOptions.
Type
Promise.<PDFNet.Convert.XODOutputOptions>

<static> createXPSOutputOptions()

Method to create an XPSOutputOptions object
Returns:
A promise that resolves to a PDFNet.Convert.XPSOutputOptions.
Type
Promise.<PDFNet.Convert.XPSOutputOptions>

<static> docToEmf(in_pdfdoc, in_filename)

Convert the PDFDoc to EMF and save to the specified path
Parameters:
Name Type Description
in_pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc the PDFDoc to convert to EMF
in_filename string the path to the EMF files to create, one file per page
Returns:
Type
Promise.<void>

<static> docToSvg(in_pdfdoc, in_filename)

Parameters:
Name Type Description
in_pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc
in_filename string
Returns:
Type
Promise.<void>

<static> docToSvgWithOptions(in_pdfdoc, in_filename [, options])

Convert the PDFDoc to SVG and save to the specified path
Parameters:
Name Type Argument Description
in_pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc the PDFDoc to convert to SVG
in_filename string the path to the SVG files to create, one file per page
options PDFNet.Obj | PDFNet.Convert.SVGOutputOptions <optional>
the conversion options
Returns:
Type
Promise.<void>

<static> fileToEpub(in_inputFilename, in_outputFilename [, html_options] [, epub_options])

Convert a file to EPUB format and save to the specified path
Parameters:
Name Type Argument Description
in_inputFilename string the file to convert to EPUB
in_outputFilename string the path to the EPUB file to create
html_options PDFNet.Obj | PDFNet.Convert.HTMLOutputOptions <optional>
the conversion options
epub_options PDFNet.Obj | PDFNet.Convert.EPUBOutputOptions <optional>
the conversion options
Returns:
Type
Promise.<void>

<static> fileToHtml(in_inputFilename, in_outputPath [, options])

Convert a file to HTML and save to the specified path
Parameters:
Name Type Argument Description
in_inputFilename string the file to convert to HTML
in_outputPath string the path to where generated content will be stored
options PDFNet.Obj | PDFNet.Convert.HTMLOutputOptions <optional>
the conversion options
Returns:
Type
Promise.<void>

<static> fileToTiff(in_inputFilename, in_outputFilename [, options])

Convert a file to multipage TIFF and save to the specified path
Parameters:
Name Type Argument Description
in_inputFilename string the file to convert to multipage TIFF
in_outputFilename string the path to the EPUB file to create
options PDFNet.Obj | PDFNet.Convert.TiffOutputOptions <optional>
the conversion options
See:
  • TiffOutputOptions
Returns:
Type
Promise.<void>

<static> fileToXod(in_inputFilename, in_outputFilename [, options])

Convert the input file to XOD format and save to the specified path
Parameters:
Name Type Argument Description
in_inputFilename string the file to convert to XOD
in_outputFilename string the path to the XOD file to create
options PDFNet.Obj | PDFNet.Convert.XODOutputOptions <optional>
the conversion options
Returns:
Type
Promise.<void>

<static> fileToXodStream(in_filename [, options])

Generate a stream that incrementally converts the input file to XOD format.
Parameters:
Name Type Argument Description
in_filename string the file to convert to XOD
options PDFNet.Obj | PDFNet.Convert.XODOutputOptions <optional>
the conversion options
See:
  • XODOutputOptions
  • ToPdf()
Returns:
A promise that resolves to a filter from which the file can be read incrementally.
Type
Promise.<PDFNet.Filter>

<static> fileToXps(in_inputFilename, in_outputFilename [, options])

Convert the input file to XPS format and save to the specified path
Parameters:
Name Type Argument Description
in_inputFilename string the file to convert to XPS
in_outputFilename string the path to the XPS file to create
options PDFNet.Obj | PDFNet.Convert.XPSOutputOptions <optional>
the conversion options
See:
  • XPSOutputOptions
  • ToPdf()
Returns:
Type
Promise.<void>

<static> fromCAD(in_pdfdoc, in_filename [, opts])

Parameters:
Name Type Argument Description
in_pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc
in_filename string
opts PDFNet.Obj | PDFNet.Convert.CADConvertOptions <optional>
Returns:
Type
Promise.<void>

<static> fromEmf(in_pdfdoc, in_filename)

Convert the specified EMF to PDF and append converted pages to to the specified PDF document. EMF will be fitted to the page.
Parameters:
Name Type Description
in_pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc the PDFDoc to append to
in_filename string the path to the EMF document to convert
Returns:
Type
Promise.<void>

<static> fromText(in_pdfdoc, in_filename [, options])

Convert the specified plain text file to PDF and append converted pages to the specified PDF document.
Parameters:
Name Type Argument Description
in_pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc the PDFDoc to append to
in_filename string the path to the plain text document to convert
options PDFNet.Obj <optional>
the conversion options. The available options are: | Option Name | Type | Note | |-------------------------|---------|---------------------------------------------------------| | BytesPerBite | Integer | In bytes. Use for streaming conversion only. | | FontFace | String | Set the font face used for the conversion. | | FontSize | Integer | Set the font size used for the conversion. | | LineHeightMultiplier | Double | Set the line height multiplier used for the conversion. | | MarginBottom | Double | In inches. Set the bottom margin of the page. | | MarginLeft | Double | In inches. Set the left margin of the page. | | MarginRight | Double | In inches. Set the right margin of the page. | | MarginTop | Double | In inches. Set the top margin of the page. | | PageHeight | Double | In inches. Set the page height. | | PageWidth | Double | In inches. Set the page width. | | UseSourceCodeFormatting | Boolean | Set whether to use mono font for the conversion. |
Returns:
Type
Promise.<void>

<static> fromTiff(in_pdfdoc, in_data)

Parameters:
Name Type Description
in_pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc
in_data PDFNet.Filter
Returns:
Type
Promise.<void>

<static> fromXps(in_pdfdoc, in_filename)

Convert the specified XPS document to PDF and append converted pages to the specified PDF document.
Parameters:
Name Type Description
in_pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc the PDFDoc to append to
in_filename string the path to the XPS document to convert
Returns:
Type
Promise.<void>

<static> fromXpsMem(in_pdfdoc, buf)

Convert the specified XPS document contained in memory to PDF and append converted pages to the specified PDF document.
Parameters:
Name Type Description
in_pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc the PDFDoc to append to
buf ArrayBuffer | Int8Array | Uint8Array | Uint8ClampedArray the buffer containing the xps document
Returns:
Type
Promise.<void>

<static> office2PDF(input [, options])

Convert the an office document (in .docx, .xlsx, pptx, or .doc format) to pdf.
Parameters:
Name Type Argument Description
input string | ArrayBuffer Either a url from which to download the file or an ArrayBuffer containing the file data.
options PDFNet.Obj <optional>
An object containing conversion options
Returns:
A promise that resolves to a "PDFDoc".
Type
Promise.<PDFNet.PDFDoc>

<static> office2PDFBuffer(input [, options])

Parameters:
Name Type Argument Description
input string | ArrayBuffer Either a url from which to download the file or an ArrayBuffer containing the file data.
options PDFNet.Obj <optional>
An object containing conversion options
Returns:
A promise that resolves to an Uint8Array containing the resulting PDF data.
Type
Promise.<Uint8Array>

<static> officeToPdfWithFilter(in_stream [, options])

Convert the an office document (in .docx, .xlsx, pptx, or .doc format) to pdf and append to the specified PDF document. This conversion is performed entirely within PDFNet, and does not rely on Word interop or any other external functionality.
Parameters:
Name Type Argument Description
in_stream PDFNet.Filter the source document data.
options PDFNet.Obj <optional>
the conversion options
See:
  • ConversionOptions
  • StreamingPDFConversion() if you would like more control over the conversion process
Returns:
A promise that resolves to a PDFDoc object
Type
Promise.<PDFNet.PDFDoc>

<static> officeToPdfWithPath(in_filename [, options])

Convert the an office document (in .docx, .xlsx, pptx, or .doc format) to pdf and append to the specified PDF document. This conversion is performed entirely within PDFNet, and does not rely on Word interop or any other external functionality.
Parameters:
Name Type Argument Description
in_filename string the path to the source document.
options PDFNet.Obj <optional>
the conversion options
See:
  • ConversionOptions
  • StreamingPDFConversion() if you would like more control over the conversion process
Returns:
A promise that resolves to a PDFDoc object
Type
Promise.<PDFNet.PDFDoc>

<static> pageToEmf(in_page, in_filename)

Convert the Page to EMF and save to the specified path
Parameters:
Name Type Description
in_page PDFNet.Page the Page to convert to EMF
in_filename string the path to the EMF file to create
Returns:
Type
Promise.<void>

<static> pageToHtml(page)

Parameters:
Name Type Description
page PDFNet.Page
Returns:
A promise that resolves to an object of type: "string"
Type
Promise.<string>

<static> pageToSvg(in_page, in_filename)

Parameters:
Name Type Description
in_page PDFNet.Page
in_filename string
Returns:
Type
Promise.<void>

<static> pageToSvgWithOptions(in_page, in_filename [, options])

Convert the Page to SVG and save to the specified path
Parameters:
Name Type Argument Description
in_page PDFNet.Page the Page to convert to SVG
in_filename string the path to the SVG file to create
options PDFNet.Obj | PDFNet.Convert.SVGOutputOptions <optional>
the conversion options
Returns:
Type
Promise.<void>

<static> printerGetMode()

Get the current mode for print jobs.
Returns:
A promise that resolves to the current print mode
Type
Promise.<number>
Example
Return value enum:
<pre>
PDFNet.Convert.PrinterMode = {
	e_auto : 0
	e_interop_only : 1
	e_printer_only : 2
	e_prefer_builtin_converter : 3
}
</pre>

<static> printerGetPrinterName()

Get the name of the PDFNet printer installed in this process session.
Returns:
A promise that resolves to the Unicode name of the PDFNet printer
Type
Promise.<string>

<static> printerInstall( [in_printerName])

Install the PDFNet printer. Installation can take a few seconds, so it is recommended that you install the printer once as part of your deployment process. Duplicated installations will be quick since the presence of the printer is checked before installation is attempted. There is no need to uninstall the printer after conversions, it can be left installed for later access.
Parameters:
Name Type Argument Description
in_printerName string <optional>
the name of the printer to install and use for conversions. If in_printerName is not provided then the name "PDFTron PDFNet" is used.
Returns:
Type
Promise.<void>

<static> printerIsInstalled( [in_printerName])

Determine if the PDFNet printer is installed
Parameters:
Name Type Argument Description
in_printerName string <optional>
the name of the printer to install and use for conversions. If in_printerName is not provided then the name "PDFTron PDFNet" is used.
Returns:
A promise that resolves to true if the named printer is installed, false otherwise
Type
Promise.<boolean>

<static> printerSetMode(print_mode)

Configure how PDFNet prints documents.
Parameters:
Name Type Description
print_mode number
PDFNet.Convert.PrinterMode = {
	e_auto : 0
	e_interop_only : 1
	e_printer_only : 2
	e_prefer_builtin_converter : 3
}
set the print mode. Default is e_auto.
Returns:
Type
Promise.<void>

<static> printerSetPrinterName( [in_printerName])

Parameters:
Name Type Argument Description
in_printerName string <optional>
Returns:
Type
Promise.<void>

<static> printerUninstall()

Uninstall all printers using the PDFNet printer driver.
Returns:
Type
Promise.<void>

<static> requiresPrinter(in_filename)

Utility function to determine if ToPdf or ToXps will require the PDFNet printer to convert a specific external file to PDF.
Parameters:
Name Type Description
in_filename string the path to the document to be checked
Returns:
A promise that resolves to true if ToPdf requires the printer to convert the file, false otherwise.
Type
Promise.<boolean>

<static> streamingPdfConversionWithFilter(in_stream [, options])

Create a DocumentConversion object suitable for converting an office document (in .docx, .xlsx, pptx, or .doc format) to pdf and appending to the specified PDF document. This conversion will be performed entirely within PDFNet, and does not rely on Word interop or any other external functionality. This method does not perform any conversion logic and can be expected to return quickly. To do the actual conversion, use the returned DocumentConversion object.
Parameters:
Name Type Argument Description
in_stream PDFNet.Filter the source document data.
options PDFNet.Obj | PDFNet.Convert.ConversionOptions <optional>
the conversion options
See:
  • DocumentConversion
  • ConversionOptions
Returns:
A promise that resolves to a DocumentConversion object which encapsulates this particular conversion.
Type
Promise.<PDFNet.DocumentConversion>

<static> streamingPdfConversionWithPath(in_filename [, options])

Create a DocumentConversion object suitable for converting a file to pdf. Handles incoming files in .docx, .xlsx, pptx, .doc, .png, .jpg, .bmp, .gif, .jp2, .tif, .txt, .xml and .md format This conversion will be performed entirely within PDFNet, and does not rely on any external functionality. This method allows for more control over the conversion process than the single call ToPDF() interface. It does not perform any conversion logic immediately, and can be expected to return quickly. To perform the actual conversion, use the returned DocumentConversion object.
Parameters:
Name Type Argument Description
in_filename string the path to the source document.
options PDFNet.Obj | PDFNet.Convert.ConversionOptions <optional>
the conversion options
See:
  • DocumentConversion
  • ConversionOptions
Returns:
A promise that resolves to a DocumentConversion object which encapsulates this particular conversion.
Type
Promise.<PDFNet.DocumentConversion>

<static> streamingPdfConversionWithPdfAndFilter(in_pdfdoc, in_stream [, options])

Create a DocumentConversion object suitable for converting an office document (in .docx, .xlsx, pptx, or .doc format) to pdf and appending to the specified PDF document. This conversion will be performed entirely within PDFNet, and does not rely on Word interop or any other external functionality. This method does not perform any conversion logic and can be expected to return quickly. To do the actual conversion, use the returned DocumentConversion object.
Parameters:
Name Type Argument Description
in_pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc the conversion result will be appended to this pdf.
in_stream PDFNet.Filter the source document data.
options PDFNet.Obj | PDFNet.Convert.ConversionOptions <optional>
the conversion options
See:
  • DocumentConversion
  • ConversionOptions
Returns:
A promise that resolves to a DocumentConversion object which encapsulates this particular conversion.
Type
Promise.<PDFNet.DocumentConversion>

<static> streamingPdfConversionWithPdfAndPath(in_pdfdoc, in_filename [, options])

Create a DocumentConversion object suitable for converting a file to pdf and appending to the specified PDF document. Handles incoming files in .docx, .xlsx, pptx, .doc, .png, .jpg, .bmp, .gif, .jp2, .tif, .txt, .xml and .md format This conversion will be performed entirely within PDFNet, and does not rely on any external functionality. This method allows for more control over the conversion process than the single call ToPDF() interface. It does not perform any conversion logic immediately, and can be expected to return quickly. To perform the actual conversion, use the returned DocumentConversion object.
Parameters:
Name Type Argument Description
in_pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc the conversion result will be appended to this pdf.
in_filename string the path to the source document.
options PDFNet.Obj | PDFNet.Convert.ConversionOptions <optional>
the conversion options
See:
  • DocumentConversion
  • ConversionOptions
Returns:
A promise that resolves to a DocumentConversion object which encapsulates this particular conversion.
Type
Promise.<PDFNet.DocumentConversion>

<static> toEpub(in_pdfdoc, in_outputFilename [, html_options] [, epub_options])

Convert the PDFDoc to EPUB format and save to the specified path
Parameters:
Name Type Argument Description
in_pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc the PDFDoc to convert to EPUB
in_outputFilename string the path to the EPUB file to create
html_options PDFNet.Obj | PDFNet.Convert.HTMLOutputOptions <optional>
the conversion options
epub_options PDFNet.Obj | PDFNet.Convert.EPUBOutputOptions <optional>
the conversion options
Returns:
Type
Promise.<void>

<static> toHtml(in_pdfdoc, in_outputPath [, options])

Convert the PDF to HTML and save to the specified path
Parameters:
Name Type Argument Description
in_pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc the PDF doc to convert to HTML
in_outputPath string the path to where generated content will be stored
options PDFNet.Obj | PDFNet.Convert.HTMLOutputOptions <optional>
the conversion options
Returns:
Type
Promise.<void>

<static> toPdf(in_pdfdoc, in_filename)

convert the file or document to PDF and append to the specified PDF document
Parameters:
Name Type Description
in_pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc the PDFDoc to append the converted document to. The PDFDoc can then be converted to XPS, EMF or SVG using the other functions in this class.
in_filename string the path to the document to be converted to pdf
Returns:
Type
Promise.<void>

<static> toTiff(in_pdfdoc, in_outputFilename [, options])

Convert the PDF to multipage TIFF and save to the specified path
Parameters:
Name Type Argument Description
in_pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc the PDF doc to convert to multipage
in_outputFilename string the path to the EPUB file to create
options PDFNet.Obj | PDFNet.Convert.TiffOutputOptions <optional>
the conversion options
See:
  • TiffOutputOptions
Returns:
Type
Promise.<void>

<static> toXod(in_pdfdoc, in_outputFilename [, options])

Convert the input file to XOD format and save to the specified path
Parameters:
Name Type Argument Description
in_pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc the PDFDoc to convert to XOD
in_outputFilename string the path to the XOD file to create
options PDFNet.Obj | PDFNet.Convert.XODOutputOptions <optional>
the conversion options
Returns:
Type
Promise.<void>

<static> toXodStream(in_pdfdoc [, options])

Generate a stream that incrementally converts the input file to XOD format.
Parameters:
Name Type Argument Description
in_pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc the PDFDoc to convert to XOD
options PDFNet.Obj | PDFNet.Convert.XODOutputOptions <optional>
the conversion options
See:
  • XODOutputOptions
  • ToPdf()
Returns:
A promise that resolves to a filter from which the file can be read incrementally.
Type
Promise.<PDFNet.Filter>

<static> toXps(in_pdfdoc, in_filename [, options])

Convert the PDFDoc to XPS and save to the specified path
Parameters:
Name Type Argument Description
in_pdfdoc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc the PDFDoc to convert to XPS
in_filename string the path to the document to create
options PDFNet.Obj | PDFNet.Convert.XPSOutputOptions <optional>
the conversion options
See:
  • XPSOutputOptions
Returns:
Type
Promise.<void>