Hi,
I have latest version aspose.word 22.6.0 and Im having issue converting from docx to PDF with password.
For example; the link (https://www.google.com/test/test1/test2
) will endup becoming (https://www.goog/
)
You can see my sample file below (PDF password = 1234)
test.docx (12.0 KB)
test.pdf (15.9 KB)
Below is the script that I developed.
String encryptFile(String input,String output){
com.aspose.words.License license = new com.aspose.words.License();
license.setLicense("Aspose.Words.Java.lic");
//ExStart: SimpleStringReplacement
// Load a Word DOCX document by creating an instance of the Document class.
Document doc = new Document( input + "test.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
//Adding password to PDF
PdfSaveOptions saveOptions = new PdfSaveOptions();
// Create encryption details and set owner password.
PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails("1234","");
// Start by disallowing all permissions.
encryptionDetails.setPermissions(PdfPermissions.DISALLOW_ALL);
// Enable encryption via the "EncryptionDetails" property.
saveOptions.setEncryptionDetails(encryptionDetails);
String outputFilename = output + "/" + "test.pdf";
// Save the result.
doc.save(outputFilename,saveOptions);
//ExEnd: SimpleStringReplacement
return outputFilename;
}
Kindly advice the best step to rectify this issue.
Thanks.
Nurhazwan Yusof