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

Free Support Forum - aspose.com

Pdf not saved when handling hyperlinks

Hi support,

If an internal hyperlink has no target destination, the Pdf file is not saved.
Please take a look.

Thank you,
Milan



Hello Milan,

I've tried to reproduce the issue using the following code snippet but I am unable to generate it. Can you please take a look and share the code snippet that you are using.

[Java]

//Instantiate a Pdf object by calling its empty constructor
Pdf pdf1 = new Pdf();
//Create a section in the Pdf object
Section sec1 = pdf1.getSections().add();

//Create text paragraph with the reference of a section
Text text1 = new Text(sec1);
//Add the text paragraph in the paragraphs collection of the section
sec1.getParagraphs().add(text1);
//Add a text segment in the text paragraph
Segment segment1 = text1.getSegments().add("this is a local link");
//Set the text in the text segment to be underlined
segment1.getTextInfo().setUnderLine(true);

//Set the link type of the text segment to Local
//Assign the id of the desired paragraph as a target id for the text segment
segment1.setHyperLink(new HyperLinkToLocalPdf("product1"));
//Create a text paragraph to be linked with the text segment
Text text3 = new Text(sec1,"product 1 info ...");
//Add the text paragraph to paragraphs collection of the section
sec1.getParagraphs().add(text3);
//Set this paragraph to be the first so that it can be displayed in a separate
//page in the document
text3.setFirstParagraph(true);

//Set the id of this text segment to "product1"
//text3.setID("product1"); // If I comment this line, error is displayed while compiling.

// save the PDF file
FileOutputStream out = new FileOutputStream(new File("d:/pdftest/Text_Rotating.pdf"));
pdf1.save(out);

Hi codewarior,

Your code shows exactly what I said. If I run-it, I get :
java.lang.RuntimeException: The name ‘product1’ has no local destination.
at com.aspose.pdf.elements.eu.a(Unknown Source)
at com.aspose.pdf.elements.cd.for(Unknown Source)
at com.aspose.pdf.elements.g8.for(Unknown Source)
at com.aspose.pdf.elements.Pdf.a(Unknown Source)
at com.aspose.pdf.elements.Pdf.save(Unknown Source)

So the error is thrown when saving. My thought is : the fact that an internal hyperlink hasn’t a local destination shouldn’t be a reason to not save a pdf file. Actually, the file is saved, but its size on disk is 0.

Regards,
Milan

Hi milan,

We have resolved this issue. You can try the hotfix in the attachment.

Thank you for using our product.

The issues you have found earlier (filed as 10106) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.