Call the convert method of the Converter class instance and pass the filename for the converted document and the instance of ConvertOptions from the previous step.
The following code snippet shows how to convert password-protected document:
importcom.groupdocs.conversion.Converter;importcom.groupdocs.conversion.options.convert.PdfConvertOptions;importcom.groupdocs.conversion.options.load.WordProcessingLoadOptions;publicclassLoadPasswordProtectedFile{publicstaticvoidloadPasswordProtectedFile(){// Set file path
StringfilePath="./password-protected.docx"// Instantiate load options and set password
WordProcessingLoadOptionsloadOptions=WordProcessingLoadOptions()loadOptions.setPassword("12345");// Specify source file path and load options
Converterconverter=newConverter(filePath,()->loadOptions);// Specify output file location and convert options
StringoutputPath="./password-protected.pdf"PdfConvertOptionsconvertOptions=PdfConvertOptions()convertOptions.setPassword("67890");// Convert and save to output path
converter.convert(outputPath,convertOptions)}publicstaticvoidmain(String[]args){loadPasswordProtectedFile();}}
password-protected.docx is sample file used in this example. Click here to download it.
password-protected.pdf is converted PDF document. Click here to download it. The file is password-protected. Password is 67890.
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.