Free Support Forum - aspose.com

Link does not work

Hi,

I experienced some issue when we imported an PDF with a link (page 1), we enlarge the page and add stamp and insert Header and Footer, but the link doesn't work any more:

byte[] inputContent = File.ReadAllBytes(@"d:\HF\PDFInput.pdf"]);

using (MemoryStream inputStreamPdf = new MemoryStream(inputContent))

{

Aspose.Pdf.Document doc = new Aspose.Pdf.Document(inputStreamPdf);
OutlineItemCollection bk = new OutlineItemCollection(doc.Outlines);

...

}

I found inside bk count is 0

I tried:

PdfBookmarkEditor editor = new PdfBookmarkEditor();
editor.BindPdf(@"d:\HF\PDFInput.pdf");
Bookmarks bms = editor.ExtractBookmarks();
foreach (Bookmark bm in bms)
{
Console.WriteLine("OutputPdf000.pdf has a bookmark of "+bm.Title);
}

and bms also count is 0

I tried Hyperlink way:

AnnotationSelector selector = new AnnotationSelector(new LinkAnnotation(page, Aspose.Pdf.Rectangle.Trivial));
page.Accept(selector);
LinkAnnotation linkAnnot = (LinkAnnotation)page.Annotations[1];

foreach (Annotation annotation in selector.Selected)

{

LinkAnnotation link = (LinkAnnotation)annotation;

}

the annotation is not empty, but found link.Action is null, there is no link at all!

while when open the PDFInput.pdf, the link(13) is there and click it and move to the second page, so what's the problem?

I attached the pdf

Thanks,

Jack

Hi Jack,


Thanks
for using our products.

I have tested the scenario and I am able to reproduce the same problem. For the sake of correction, I have logged it in our issue tracking system as PDFNEWNET-34756. We will investigate this issue in details and will keep you updated on the status of a correction.

We apologize for your inconvenience.

Hi Jack,


Thanks for your patience.

We have further investigated the issue reported earlier and have found that the document which you ahve shared does not contain any bookmarks so the following code gives 0 for doc.Outlines.Count and this behavior is correct:

[C#]

Aspose.Pdf.Document
doc = new Aspose.Pdf.Document(“c:/pdftest/PDFInput (1).pdf”);<o:p></o:p>

int bookmarksCount = doc.Outlines.Count; // <-- 0

Console.WriteLine(bookmarksCount);


However the document contains a hyperlink (LinkAnnotation) that can be accessed using code snippet specified below.

[C#]

Aspose.Pdf.Document doc = new Aspose.Pdf.Document("c:/pdftest/PDFInput (1).pdf");

LinkAnnotation linkAnnot = (LinkAnnotation)doc.Pages[1].Annotations[1];

// linkAnnot.Action is null but linkAnnot.Destination is not null for this link

// (this is a feature of customer document)

ExplicitDestination dest = (ExplicitDestination)linkAnnot.Destination;

int pageNumber = dest.PageNumber; // pageNumber is 2

Console.WriteLine(pageNumber);


PS, The bug was that the linkAnnot.Destination was null for that link and its hotfix will become available in upcoming release version of Aspose.Pdf for .NET 7.7.0.

The issues you have found earlier (filed as PDFNEWNET-34756) have been fixed in Aspose.Pdf for .NET 7.7.0.


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