Load PDF document with options

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

  • Format - the document type is auto detected during loading, however you can specify explicitly the type of the source document. Available options are: Pdf, Epub, Xps, Tex, Ps, Pcl
  • RemoveEmbeddedFiles - specifies to remove embedded files from source document during conversion
  • Password - password to unlock protected document
  • HidePdfAnnotations -  specifies that annotations in the source document must be hidden
  • FlattenAllFields - specifies that all fields in the source document will be flatten during conversion

Flatten all fields

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

Contracts.Func<LoadOptions> getLoadOptions = () => new PdfLoadOptions
{
    FlattenAllFields = true
};
using (Converter converter = new Converter("sample.pdf", getLoadOptions))
{
    WordProcessingConvertOptions options = new WordProcessingConvertOptions();
    converter.Convert("converted.docx", options);
}

Hide annotations

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

Contracts.Func<LoadOptions> getLoadOptions = () => new PdfLoadOptions
{
    HidePdfAnnotations = true
};
using (Converter converter = new Converter("sample.pdf", getLoadOptions))
{
    WordProcessingConvertOptions options = new WordProcessingConvertOptions();
    converter.Convert("converted.docx", options);
}

Remove embedded files

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

Contracts.Func<LoadOptions> getLoadOptions = () => new PdfLoadOptions
{
    RemoveEmbeddedFiles = true
};
using (Converter converter = new Converter("sample.pdf", getLoadOptions))
{
    WordProcessingConvertOptions options = new WordProcessingConvertOptions();
    converter.Convert("converted.docx", options);
}

More resources

Examples and Demos

Please find more use-cases and complete C# sources of our backend and frontend examples and try them for free!