These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How to remove links pointing to the same page?

oald
Registered: Oct 12 2011
Posts: 17
Answered

I have PDF documents with Links which point to sections referenced (e.g. link of text "Section 2.2" points to the actual page number of "Section 2.2"), but as the links are created from cross-references during rendition from Word to PDF, there are cases that the destination page number and source page number of the links are the same (e.g. links of text "Section 2.2" on page 9 are created with the destination of page 9 which is the actual page number of "Section 2.2"), I want to remove all these links, but I don't know how to get the destination page number by JavaScript, could you check me codes below and advise? Your help is really appreciated!
   
for (var i = 0; i < this.numPages; i++)
{
var box = this.getPageBox("Crop", i);
var linksofOnePage = this.getLinks(i, box);
for (var j = 0; j< linksofOnePage.length; j++)
{
if linksofOnePage[j]...
{
this.removeLinks(i,linksofOnePage[j].rect);
}
}
}

My Product Information:
Acrobat Pro 8.1.6, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Unfortunately, it's not possible with a JS script.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

oald
Registered: Oct 12 2011
Posts: 17
Hi try67,

Thanks for your answer, I check the JS API Reference and find that there is method "setAction", I wonder if there is method like "getAction" to get the destination page of the link, if so, I can make it.

PS: We need to add navigation (Bookmarks, Links) to PDF documents in our daily work, I see that JavaScript only provides limited properties and methods for Bookmarks and Links, is there any way to access more properties and methods? There are commercial Plug-ins (e.g. ISIToolBox) which can manipulate Bookmarks and Links in various ways, are they developed by C++ and can access low-level objects in PDF object model?
try67
Expert
Registered: Oct 30 2008
Posts: 2398
No, there's isn't a getAction() method for bookmarks or links, which is why it's not possible (actually, with bookmarks there's a workaround, executing the action, but that's not available for links...).

You're right. JS is quite limited in this field. And yes, you can use various tools to create fully functioning links or bookmarks in a PDF. I prefer to use Java libraries like PDFBox or iText, but there are various other options available, depending on your programming language of choice.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

oald
Registered: Oct 12 2011
Posts: 17
Thanks for your follow-up!

As mentioned in the introduction of the Adobe SDK: "You can develop software that integratew with Acrobat and Adobe reader in three ways: JavaScript, plug-ins and IAC", "Plug-ins can access and manipulate low-level objects in the PDF object model, such as the Cos layer.", then I wonder if I can develop the tool to manipulate Bookmarks and Links by plug-ins using C++.NET in Microsoft Visual Studio 2005?

It is my first time to know PDFBox and iText, can I develop plug-ins by PDFBox and iText?

Thanks a lot!
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Accepted Answer
No, not plugins, but stand-alone apps that can edit PDF files. In fact, if you go that route you don't need to have Acrobat (or even Reader) at all. The tool can run independently of Adobe software.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com