Get default load options for a source format
Leave feedback
GroupDocs.Conversion allows you to get default load options for the source document format. This will allow you to get default load options runtime, knowing the source format.
To get default options, follow these steps:
- Call the static GetPossibleConversion method of the Converter class with source file extension as a parameter.
- From received possible conversion read the LoadOptions property.
- Create an instance of the Converter class and pass source document path as a constructor parameter and load options from the previous step.
- Instantiate the appropriate ConvertOptions class e.g. (PdfConvertOptions, WordProcessingConvertOptions, SpreadsheetConvertOptions etc.).
- Call the Convert method of the Converter class instance and pass filename for the converted document and the instance of ConvertOptions from the previous step.
The following code snippet shows how to get default load options for a Word processing document:
With v24.10 and later:
var possibleConversions = Converter.GetPossibleConversions("docx");
var loadOptions = (WordProcessingLoadOptions) possibleConversions.LoadOptions;
loadOptions.Password = "12345";
using (Converter converter = new Converter("password_protected.docx", (LoadContext loadContext) => loadOptions))
{
var convertOptions = new PdfConvertOptions();
converter.Convert(outputFile, convertOptions);
}
Before v24.10:
var possibleConversions = Converter.GetPossibleConversions("docx");
var loadOptions = (WordProcessingLoadOptions) possibleConversions.LoadOptions;
loadOptions.Password = "12345";
using (Converter converter = new Converter("password_protected.docx", () => loadOptions))
{
var convertOptions = new PdfConvertOptions();
converter.Convert(outputFile, convertOptions);
}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.