Load PDF document with options

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Conversion MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-conversion -- dnx GroupDocs.Conversion.Mcp --yes
Folders, licensing and more →

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)