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

How to merge png files into a single PDF... by using javascript

gavin2u
Registered: Jul 3 2009
Posts: 76
Answered

Hi, all

I have a range of PNG files at hand, now, I wanna get these files merged into a single PDF file.

Is it possible to combine them to a single PDF document by using acrobat scripting?

These PNG files are arranged as follows,
----------------------------------------
docname_Page_001.png
docname_Page_002.png
docname_Page_003.png
...
docname_Page_125.png
----------------------------------------

Any assistance would be much appreciated.

Regards,

- gavin

My Product Information:
Acrobat Pro 9.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yes it is, but there is a much easier way using the "Create PDF > From multiple files..." menu item.But if you really want to use JavaScript it's a bit awkward, but it can be done. First, this has to be written as an automation script. The code itself will need to be placed in a privileged function in a folder level script.

Use the "app.openDoc()" function with the "bUseConv" option. You'll need to run this on every png file, then use the "doc.insertPages()" function to place them all in the same file.

There's lots of picky details to this process, you can find most of what you need in the Acrobat JavaScript Reference.

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

gavin2u
Registered: Jul 3 2009
Posts: 76
My hearty thanks for you help. It is so useful.

Yep, I known these operations are a bit awkward, but merging files into a single pdf is just a part of my js code's mission.

I will try it out myself right now.

Thanks again.

Regards,

- gavin
gavin2u
Registered: Jul 3 2009
Posts: 76
Hi, thomp

Thanks.

I have merged those png files successfully. This is important, 'couse I've got a range of png sets.

I wanna process those png files automatically. :)