3

Is it possible to merge several PDF's into one PDF document in Matlab while controlling the sequence in which the PDF's are merged?

Example:

I have a folder with PDF's:

docu1.pdf
docu2.pdf
docu3.pdf
docu4.pdf

I want to merge them to one PDF document with the following page mapping:

page 1: docu3.pdf
page 2: docu4.pdf
page 3: docu2.pdf
page 4: docu1.pdf

The above order is just an example, I want to be able to control the sequence in the script.

Saaru Lindestøkke
  • 2,067
  • 1
  • 25
  • 51

1 Answers1

5

You could merge your PDF files in the command line using ghostscript, and you can invoke a command line from Matlab using the system operator.

Combining the two you could do:

command = 'gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=out.pdf in1.pdf in2.pdf';
[status,cmdout] = system(command)
Community
  • 1
  • 1
yms
  • 10,361
  • 3
  • 38
  • 68