Free Support Forum - aspose.com

Modifying Hyperlinks

Hi there,

I’m just wondering if it’s possible to use ExtractLink of PDFContentEditor and change the properties of all the links found in a PDF document.

For example, say I have a pdf document with URL type hyperlinks. Can I use PDFContentEditor and bind that document, then use ExtractLink to go through all the links and change the link type to a page link, set the DesPageNum to a page number in the same document?

Example:
PdfContentEditor ceditor = new PdfContentEditor();
string inFile = “c:\testdata\testXML3.pdf”;
FileStream inStream = new FileStream(inFile, FileMode.Open, FileAccess.ReadWrite);
ceditor.BindPdf(inStream);
int destinationpage = 3

ArrayList linkArray = ceditor.ExtractLink();
LinkInfo[] links = (LinkInfo[])linkArray.ToArray(typeof(LinkInfo));

for (int k = 0; k < linkArray.Count; k++)
{
links[k].DesPageNum = destinationpage;
links[k].ActionType = “Local”;
links[k].LinkURI = null;
links[k].DestinationViewType = “FitPage”;
}

We’re currently evaluating this product to see if we can use this tool in our project.

Thanks,
Hubert

Hi,

Thank you for considering Aspose.

I am sorry but you cannot modify the links in this manner. It is currently not supported. However you can create new links using the CreateLocalLink function.

Thanks.

Thanks for the quick reply. Looking at CreateLocalLink, it seems that I have to supply an output file. Does this mean that if I need to create 5 links in a single PDF, I will have to output to a file each time for a total of 5 times?

Hi hdumas,

when you need to create multi-links, you can use the function of Create Link repetitively as below.

System.Drawing.Rectangle rect=new System.Drawing.Rectangle(100,100, 90, 90);
PdfContentEditor editor = new PdfContentEditor();

editor.BindPdf(TestPath + "PdfContentEditor.CreateLocalLink.in.pdf");

System.Drawing.Color c=System.Drawing.Color.FromArgb(255,0,255);
editor.CreateLocalLink(TestPath+ "PdfContentEditor.CreateLocalLink.out.pdf",rect, 1, 2,c);
editor.CreateLocalLink(TestPath+ "PdfContentEditor.CreateLocalLink.out.pdf",rect, 2, 1,c);
editor.Save(TestPath+ "PdfContentEditor.CreateLocalLink.out.pdf");
If any question, please inform me.

I'm also looking at modifying / removing hyperlinks from generated PDF documents.

Is there a timeframe for when this will be supported?

Hi,

Thank you for considering Aspose.

Right now we haven't got any specific time frame about the availability of this feature. I am afraid that we have no short term plans to support this feature. But we will let you know here on this forum, if we plan to support this feature.

Thanks.