Load PDF document with options

GroupDocs.Conversion provides PdfLoadOptions to give you control over how the source PDF document will be processed. The following options could be set:

  • setFormat allows you to specify explicitly the type of the source document. Available options are: Pdf, Epub, Xps, Tex, Ps, Pcl.
  • setRemoveEmbeddedFiles whether to remove the embedded files from the source document during the conversion.
  • setPassword specifies a password to unlock the protected document.
  • setHidePdfAnnotations specifies that annotations in the source document should be hidden.
  • setFlattenAllFields specifies that all fields in the source document should be flattened during the conversion.

Flatten all fields

The following code snippet shows how to convert a PDF document and flatten all fields:

const loadOptions = new groupdocs.conversion.PdfLoadOptions()
loadOptions.setFlattenAllFields(true)

const converter = new groupdocs.conversion.Converter("sample.pdf", loadOptions)

const outputPath = "ConvertPdfAndFlattenAllFields.docx"

const convertOptions = new groupdocs.conversion.WordProcessingConvertOptions()

console.log(`Pdf document converted successfully to ${outputPath} (pdf & flatten all fields)`)
converter.convert(outputPath, convertOptions)

Hide annotations

The following code snippet shows how to convert a PDF document and hide annotations:

const loadOptions = new groupdocs.conversion.PdfLoadOptions()
loadOptions.setHidePdfAnnotations(true)

const converter = new groupdocs.conversion.Converter("sample.pdf", loadOptions)

const outputPath = "ConvertPdfAndHideAnnotations.docx"

const convertOptions = new groupdocs.conversion.WordProcessingConvertOptions()

console.log(`Pdf document converted successfully to ${outputPath} (pdf & hide annotations)`)
converter.convert(outputPath, convertOptions)

Remove embedded files

The following code snippet shows how to convert a PDF document and remove embedded files:

const loadOptions = new groupdocs.conversion.PdfLoadOptions()
loadOptions.setRemoveEmbeddedFiles(true)

const converter = new groupdocs.conversion.Converter("sample.pdf", loadOptions)

const outputPath = "ConvertPdfAndRemoveEmbeddedFiles.docx"

const convertOptions = new groupdocs.conversion.WordProcessingConvertOptions()

console.log(`Pdf document converted successfully to ${outputPath} (pdf & remove embedded files)`)
converter.convert(outputPath, convertOptions)