Links doesn't work when converting HTML to PDF with DocumentPrivilege

Hi,
I am using Aspose PDF Java v22.5. After setting DocumentPrivilege links in the PDF are not working. My html file is very simple with just one anchor tag and href to google.com. I tried setting DocumentPrivilege.getAllowAll() but doesn’t work. Attached is the HTML template I am trying to use and the pdf which I generated using Aspose PDF java.
Archive.zip (123.4 KB)

Appreciate any help/suggestions!

Thanks
Archive.zip (123.4 KB)

@pmanav

Would you please also share the sample code snippet that you are using so that we can test the scenario in our environment and address it accordingly?

Thanks for your response @asad.ali . Below is the code snippet

//function to generate HTML to PDF
private byte[] convertToPdf(byte[] input, DocumentType type) {
final com.aspose.pdf.Document document;
try(ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ByteArrayInputStream inputStream = new ByteArrayInputStream(input)) {
HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
document = new com.aspose.pdf.Document(inputStream, htmlLoadOptions);
disablePdfEditing(document);
document.save(outputStream, type.getAsposePdfFormat());
document.close();
return outputStream.toByteArray();
} catch (Exception e) {
throw new RuntimeException(“Could not convert html to pdf”, e);
}
}
// setting Privileges
private void disablePdfEditing(com.aspose.pdf.Document pdf) {
DocumentPrivilege privilege = DocumentPrivilege.getAllowAll();
PdfFileSecurity fileSecurity = new PdfFileSecurity(pdf);
fileSecurity.setPrivilege(privilege);
}

@pmanav

While using 24.3 version in our environment to test the case, we obtained different output than what you shared with us:

private void HTMLtoPDFStreams() throws Exception {
    final com.aspose.pdf.Document document;
    File inFile = new File(dataDir + "test.html");
    byte inBytes[] = java.nio.file.Files.readAllBytes(inFile.toPath());
    try(ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        ByteArrayInputStream inputStream = new ByteArrayInputStream(inBytes)) {
        HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
        document = new com.aspose.pdf.Document(inputStream, htmlLoadOptions);
        disablePdfEditing(document);
        document.save(dataDir + "output.pdf");
        document.close();
    } catch (Exception e) {
        // Handle exception
    }
}

// Setting privileges
private void disablePdfEditing(com.aspose.pdf.Document pdf) {
    com.aspose.pdf.facades.DocumentPrivilege privilege = com.aspose.pdf.facades.DocumentPrivilege.getAllowAll();
    com.aspose.pdf.facades.PdfFileSecurity fileSecurity = new com.aspose.pdf.facades.PdfFileSecurity(pdf);
    fileSecurity.setPrivilege(privilege);
}

output.pdf (100.3 KB)

Can you please check and see if its as per expectations?

Hi,

That is not an expected output. I am not expecting PDF with raw html. I am expecting PDF with rendered HTML (similar to how html renders on browser).

Thanks

@pmanav

This is how your HTML is rendering in the browser at our end.
image.png (24.1 KB)

okay. can you please try attached one. Thanks
tester.html.zip (1.1 KB)

@pmanav

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFJAVA-43865

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Thanks. Is there any portal where I can track the status of the issue?

@pmanav

You can check the status of the attached ticket at the bottom of this forum thread. Additionally, we will also keep you posted here in case of any progress towards ticket resolution.