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

Changing borderWidth on a document's links?

Jay Levitt
Registered: Nov 3 2009
Posts: 7

When Word 2007 exports PDFs, it creates borders around all the hyperlinks. I have Acrobat 9 on my Mac, and I'm trying to create a JavaScript for Acrobat that will fix these links.

I've got as far as the following folder script:

app.addMenuItem({
  cName:"Make links invisible", 
  cParent:"Tools",
  cExec:"makeLinksInvisible();"
});
 
function makeLinksInvisible() {
  for ( var p = 0; p < this.numPages; p++) 
  {
    var box = this.getPageBox("Crop", p);
    var links = this.getLinks(p, box);
 
    for each (l in links) {
      for (var att in l) {
        console.println("Link property: " + att);
      }
 
      console.println(l.borderColor);
      l.borderColor = color.white;
 
      console.println(l.borderWidth);
      l.borderWidth = 1;
 
    }
  }
 
}

When I run this against a simple PDF with one link, I can see that borderColor and borderWidth are both properties of that link. And I can get and set borderColor. But attempting to either get or set borderWidth results in an error:

Acrobat EScript Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Wizard Functions Version 9.0
Acrobat SOAP 9.0
Link property: borderColor
Link property: rect
Link property: highlightMode
Link property: borderWidth
Link property: setAction
RGB,1,1,1
InvalidGetError: Get not possible, invalid or unknown.
Link.borderWidth:21:Menu Make links invisible:Exec

What am I doing wrong? I'm running Acrobat Pro 9.2.0. A Google finds only [url=http://www.planetpdf.com/developer/article.asp?ContentID=ModifyinglinkpropertiesusingJavaScript]this script[/url], which makes me think either (a) this property used to work or (b) this property still works, but only on Windows...

My Product Information:
Acrobat Pro 9.2, Macintosh
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I'm mystified. Your code works on my Windows system without a hitch on both Acrobat 8 and 9. What's particularly interesting is that in the loop that displays the link properties it lists "borderWidth". I'd suggest a mondification to this loop as a test:
      for (var att in l) {console.println("Link property: " + att + " = " + l[att]);}

See if this chokes on the borderWidth.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Jay Levitt
Registered: Nov 3 2009
Posts: 7
Interesting.. yes, that chokes on l[att] when it gets to borderWidth! I get:

makeLinksInvisible();Link property: borderColor = RGB,1,1,1Link property: rect = 110.94000244140625,720,132.58999633789062,694.5599975585938Link property: highlightMode = InvertInvalidGetError: Get not possible, invalid or unknown.Link.borderWidth:15:Console undefined:Execundefined

Could Word be generating an invalid document? The .pdf I'm using is [url=http://dl.getdropbox.com/u/103613/Here%20is%20a%20test%20document.pdf]here[/url].
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I wouldn't say that it's an invalid link. After all it works. However the Annot dict entries are incomplete (specifically the border style dict is missing entries). There's enough there to make the link work, but not enough for Acrobat (or JavaScript) to use for editing. So, when you try to use Acrobat (or JavaScript) to edit the link properties it chokes. You could try using an earlier version of Acrobat, like Acrobat 5, which is more forgiving with the format.

If you want to work with these links in Acrobat you'll need to generate the files in a different way. For example, with the Acrobat add-in to Word which uses PDFMaker.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Jay Levitt
Registered: Nov 3 2009
Posts: 7
Thanks.. PDFMaker apparently doesn't support Word 2007, and I don't have Acrobat for Windows anyway (traded it for the Mac version), so I'll try some of the free PDF utilities and see if they produce better output from Word. I don't have a strong need to edit this particular file; I just want to be able to take any Word 2007 doc and make a PDF that's usable and non-ugly on both Mac and Windows.
Jay Levitt
Registered: Nov 3 2009
Posts: 7
PS: For future readers of the thread... As far as I can see, there's absolutely no way to reliably convert a rich Word 2007 .docx into a rich .pdf using only Office 2007 (Windows) and Adobe CS4 (Mac) without spending another $200 on Adobe Acrobat for Windows.

The Mac version doesn't come with PDFMaker for Windows. There are free PDF printers available for Windows, but once you go through the printer driver, all your links are gone, of course.

Nitro offers to recreate your links if they're to explicit targets (e.g. "http://www.google.com" remains linked), but it can't see the implicit links in the .docx. iWork Pages '09 can read the .docx, but it messes up the formatting. www.doc2pdf.net does a decent job, but still doesn't format identically to Word 2007 on more complex documents. NeoOffice can't even come close to reading the .docx correctly.

So sad.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Wow Jay, you really tested this out!! Thanks for the info. I agree, it's pretty sad that you can't do a clean conversion on the Mac to PDF and maintain the links. All I can say is that I'm shocked.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Laston Lastof
Registered: Nov 9 2009
Posts: 1
dear borders visible

what about choosing the border in word and choosing to make it invisible IN WORD
by this i mean ...
make the fill colour of the border white or what ever colour of paper you are using
see if that gets rid of your borders in the final version of PDF

regarding getting a mac ... right on best move ever
with the VM Fusion you can use Windows right on your mac and enjoy the 10000000% better screen
and also use adobe acrobat with live cycle

clearly it is insane that livecycle does not work on a mac
i had a long chat with the adobe pdf miester his self
mr. duff johnson ... and all he could say was it is very unlikley to happen and i should send any form work to his company for PDF Form Creation

I think not ... the good news is
Acrobat Pro on the Mac runs the PDF forms created on the PC with out any issues at all

YOURS
Jay Levitt
Registered: Nov 3 2009
Posts: 7
Laston - sadly, it's not that simple. Word doesn't show any borders; in Word 2007, the link looks just like it should (blue and underlined). And in Acrobat.app, there's no border on the link. In Preview.app, there IS a border!

I think Word is creating the link without specifying a border at all; Acrobat assumes that means "no border", while Preview assumes it means "black border".

My hacky workaround: it IS possible to change borderColor via Javascript. It won't let you set it to color.transparent, but it will let you set it to color.white. That may not work in a lot of cases, depending on your layout, but for my simple Word doc with lots of whitespace and high leading, it works fine.
chanteur
Registered: Dec 13 2007
Posts: 1
Is there a way to set the appearance defaults in Link Properties? Currently when I create a pdf from FrameMaker 9 using acrobat 9, all the links contain the blue underline. Since there are many links on some pages, this makes the document look a bit messy. I can select a page at a time and change the link type properties for all the links on the page to invisible rectangle, however the document is over 1600 pages long. A page-by-page process to change the link properties is not really an option. If I do a select all in any page display (other than single-page) to select the entire document, the link properties dialog box is not available. I'm thinking there has to be a way to set the default link appearance properties. Can it be done? If so, how can I do it?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The blue line you are seeing is not really part of the link. It's on the text on the page. In a PDF the link is a separate object that floats over the page text. It's either outlined or invisible. So it's the text that needs to be changed, not the link. The conversion software is the culprit here. You need to do one of two things.

1. Change settings in FrameMaker so that links do not appear with blue text and underlines
2. Change the conversion setting for links.

I don't know which will work if either, but these are the things you need to look at.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script