Wednesday, May 13, 2020

Using texexec to modify a PDF file (from the shell)

We all regularly have to modify a PDF file, either taking a part of it. The texexec program which is shipped with ConTeXt allows to do most of it, but its man page is not very helpful and its documentation is hard to find online. The previous link does not have all the important information, this other explanation (PDF) is also useful.

Here are some commands that I find the most useful, but never remind of.

  • To extract pages 1 to 5, page 7 and pages 8 to 12 from file.pdf and put it in outputfile.pdf:
    texexec --pdfselect --select=1:5,7,8:12 --result=outputfile.pdf file.pdf
  • Concatenate the PDF files file1.pdf and file2.pdf into one single file result.pdf
    texexec --pdfcopy --result=result.pdf file1.pdf file2.pdf

(To be continued)