We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to unlink the hyperlinks in output PDF using Java

Hi Team,

I am using Aspose.Words API and I want to make the links unclickable from PDF. It works ok in word files but in pdf files they are clickable. Is there a way to make the links unclickable from PDF using aspose.words?

Thank you!

@gonzaamat

Could you please ZIP and attach your input Word document, problematic PDF and expected output PDF here for testing? We will investigate the issue and provide you more information on it.

docs.zip (73.4 KB)

You can see that in the pdf file when you click in the link you are redirected to page, we want to avoid this behavior and make the link inactive as it works in the word file.

@gonzaamat

In the shared DOCX and PDF, the link is not clickable. If you want to remove the hyperlink of text, you can use the following code example. Hope this helps you.

Document doc = new Document(MyDir + "wordExample.docx");
for(Field field : doc.getRange().getFields())
{
    if(field.getType() == FieldType.FIELD_HYPERLINK)
        field.unlink();
}
doc.save(MyDir + "20.4.pdf");

Hi!

The links are added as plain text (not as hiperlinks). I changed the code to add them as hyperlinks and then mark them as unlink but it is still not working, when I click in the link it is redirecting to the page.

@gonzaamat

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a simple Java application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.