Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Help with batching MULTIPLE pdf's into a SINGLE pdf using javascript?

Community Beginner ,
Jul 16, 2021 Jul 16, 2021

Hi,

Need to create an automated way of using the Adobe Acrobat DC tool "Combine Files". Has anyone on this forum created a way to combine multiple PDF files into a single PDF? I suspect this is possible using javascript so any tips or tricks in this process is greatly appreciated.

Thanks in advance for your prompt reply.

-Greg

TOPICS
Create PDFs , How to , JavaScript
3.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Jul 24, 2021 Jul 24, 2021

Hi,
All your files must be in the same directory.

Place the "Combine Files_BB.pdf" attached file in this directory then open it.

You paste the list of files in the left field then 2 solutions:

Either you copy the script of the right field then paste it in the console (then select all and "Enter") or you import the action wizard included in this file then run it.

You will get a combined file including all (correct) files indicated. If it's possible, sort the files before run the script because the files are imported in the indicated order.

Let me know if that suits you.

@+

Capture_d’écran_2021-07-24_à_17_39_51.pngexpand image

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 16, 2021 Jul 16, 2021

FYI,

Looks like I found sample code online in a PDF document entitled, "Developing Acrobat Applications Using Javascript" on page 47. I'm not sure what is wrong but it doesn't appear to be working successfully. Any assistance is greatly apprecaited. Below is a brief description of what I'd like to accomplish but it doesn't appear to be working successfully:

Combining PDF documents
You can customize and automate the process of combining PDF documents.
If you would like to combine multiple PDF files into a single PDF document, you can do so through a series
of calls to the Doc object’s insertPages method.
Example: Creating a new document from two other documents
// Create a new PDF document:
var newDoc = app.newDoc();
// Insert doc1.pdf:
newDoc.insertPages({
nPage: -1,
cPath: "/c/temp/doc1.pdf",
});
// Insert doc2.pdf:
newDoc.insertPages({
nPage: newDoc.numPages-1,
cPath: "/c/temp/doc2.pdf",
});
// Save the new document:
newDoc.saveAs({
cPath: "/c/temp/myNewDoc.pdf";
});
// Close the new document without notifying the user:
newDoc.closeDoc(true);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 16, 2021 Jul 16, 2021

What console messages do you get? Please copy and paste them.

And how do you try to run the code (e.g. console, batch, mouse up event, privileged function...)?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 18, 2021 Jul 18, 2021

As indicated, it is not possible to read the content of a folder, but if all your files are in a same forder, you can copy then paste all the file names in a text field then use it to recover the names.

With macOS it very easy to do that, but I beleive it's a bit more complicated with a Windows OS.

I already did that, so let me know if you are interested with this solution and I'll send you an example file.

@+
P.S. Sorry, I didn't place my answer at the right place...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 23, 2021 Jul 23, 2021

Hi Bebarth,

Yes, I am interested in how you do this? I should be able to easly create a file that includes a list of the filenames I want to process easily. Can you post your answer below this reply or e-mail your solution to me?

Thanks,
Greg

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 24, 2021 Jul 24, 2021

Hi,
All your files must be in the same directory.

Place the "Combine Files_BB.pdf" attached file in this directory then open it.

You paste the list of files in the left field then 2 solutions:

Either you copy the script of the right field then paste it in the console (then select all and "Enter") or you import the action wizard included in this file then run it.

You will get a combined file including all (correct) files indicated. If it's possible, sort the files before run the script because the files are imported in the indicated order.

Let me know if that suits you.

@+

Capture_d’écran_2021-07-24_à_17_39_51.pngexpand image

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 03, 2021 Aug 03, 2021

Hi,

Apologies for the delay just wanted to inform you that the solution you provided worked! In fact, quite well and was a lot quicker than I anticipated. The only difference I noticed is the original byte count 7.93mb (8,118kb) .vs. converted 94.7mb (96,970kb). I wonder if this has anything to do with the Adobe PDF versions 1.4 .vs. 1.6.?

Thanks for sharing this Adobe SEQ. It will save me quite a bit of time.

Best,
Greg

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 04, 2021 Aug 04, 2021

Hi,

There is effectively a difference of weight between saving your file following the pdf version, but I don't think from 8 to 95MB! But I am not a specialist about that...

How many files did you merge? and what was the weight of each file?

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 04, 2021 Aug 04, 2021

Try opening the file in Acrobat and saving it under a new name using the Save As method. This will force an optimization of it and can dramatically reduce the file size.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 27, 2022 Aug 27, 2022
LATEST

Hi

this is really great I have one more request ... could you please add bookmarking field too?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 16, 2021 Jul 16, 2021

What happens when you use it? From where are you running it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 16, 2021 Jul 16, 2021

Before you spend more time on this you should know that this is only possible if you know the paths to all of the files that you want to merge. Acrobat JS can't read a folder's contents and merge all the files in it on its own, if that's your intention.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 23, 2021 Jul 23, 2021

Hi Try67,

Yes, I can create a list of the files that I want to merge and yes all files are in the same directory.

-Greg

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines