Mobile app version of vmapp.org
Login or Join
Lee3735518

: Data merge for PDF Lets say I have 100 PDFs in one folder1 (filename: 1, 2,3,4..) and another 100 PDF in another folder2 (Filename: 1,2,3,4...). Now I want to combine PDF1 in folder1 with

@Lee3735518

Posted in: #Actions #AdobeIndesign #AdobePhotoshop #Pdf #Python

Lets say I have 100 PDFs in one folder1 (filename: 1, 2,3,4..) and another 100 PDF in another folder2 (Filename: 1,2,3,4...). Now I want to combine PDF1 in folder1 with PDF1 in folder2 and so on till pdf100 from folder1 is combined with pdf100 in folder2.

The PDF in folder 1 shoudl be placed in the first page of the pdf1 in folder2. (this applies for all the pdf)

How can this be implemented? Can we use data merge? Will Photoshop be useful or indesign or acrobat reader?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Lee3735518

1 Comments

Sorted by latest first Latest Oldest Best

 

@Kimberly620

You can do this, but your asking on wrong forum. Youd much more likely get a good answer on superuser than here. Merging PDF files isn't exactly a magic science.

Tools that would come handy:


Acrobat DC Pro,as a gui tool for merging pdf files but then you'd have to run it 100 times. Can also be scripted to do this, but the scripting environment is a bit horrible (some info here). I would make a demo but i havent got acrobat DC at home (yeah i arrived took me nearly the whole trip to craft the original message).
PDF Fill
PDF-Xchange, has a gui tool for merging pdf files but then you'd have to run it 100 times.
Scripting language like python with pyPDF
Indesign
GhostScript
pdfunite
Batch scripting
...


Currently im writing this over on my phone and I'm a bit low on tools. So I'm going to show how to do this with python and pyPdf (because all I have on my phone is bash, tcsh, zsh and python. Aside the browser which implements javaScript).

#!/usr/bin/python
# -*- coding: utf-8 -*-

from pyPdf import PdfFileWriter, PdfFileReader

for i in range(1,101):
output = PdfFileWriter()
outputStream = file("output%d.pdf"%i, "wb")
for item in [r"folder1file%d.pdf"%i,r"folder2file%d.pdf"%i]:
fp = file(item,'rb')
input = PdfFileReader(fp)
output.addPage(input.getPage(0))
output.write(outputStream)
fp.close()


if you have got python but not pyPdf then run pip install pyPdf or easy_install pyPdf before running the script.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme