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

Can Javascript do this?

Acrobatica
Registered: Jul 24 2009
Posts: 15

I have a couple of documents that have common graphics and text used on every page.

In the past I have used the Touchup tools to remove these objects by hand as they are no longer needed for the intended audience.

This got me thinking if it was possible to write a script to automate the process.
Has anyone done this before? Or perhaps you have some sample code that I could use to develop.

I know the object names that identify them in the Cos tree. Is this a complex undertaking or could it done without writing pages and pages of code?

Any hints, tips, pointer or code would be most welcome.

Thankyou.

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There is no direct access to Page Content from Acrobat JavaScript. Editing content is of course against the intented usage model for Acrobat, i.e. Acrobat is not a content creation tool.

But there is some undocumented and indirect ways to get access to the content. Don't know if either will help you. First, preflight has been added to the JS DOM in Acrobat 9.1. Download the latest SDK and look in the Document Object. You might be able to create a preflight profile that does what you want, I don't know.

Next, I won't tell you how its done, but if you know a bit about Acrobat JavaScript you can get the raw bytes for the PDF file. If you want to write a PDF parser you could conceivably modify the cos level structure of a PDF from JavaScript. I wouldn't recomend this though;)

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

Acrobatica
Registered: Jul 24 2009
Posts: 15
Thankyou very much for your very informative answer Thom.

I think It would be unrealistic for me to investigate this any further based on your advice against modifying cos structures, additionally the amount of time it would take to research and develop such a parser versus the time to touch up a document will be quite considerable.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Are you looking to actually remove those object, or is just hiding them from view sufficient?
Because if so, you can probably create a script that will place a blank field on top of those item and then flatten the pages, making them disappear from the users's view.

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