Search code examples
splitfilenamespdfboxprefix

PDFBox: split pdf and output prefix


i like to use PDFBox to extract an single page from an big PDF. All my "real" PDF files are located at one directory. So if i extract one page, i like to save this page to an different directory for single pages). (or pipe it to standard out)

Question: is there a way the define an output directory or output prefix, like -prefix=/tmp/pdf-snipped-

PDFBox with option PDFSplit seams to store the splitted page at the same directory like the source pdf. But this is not so fine.

Btw: it's not an option to copy the source pdf before splitting, because there are very big (more than 1 GB)


Solution

  • To answer my own question:

    It looks like, there is no option (also no hidden) to define an output prefix or output filename.

    So I decided to download and change the PDFbox source code and added an new option ("prefix") to define an path to store the PDF snipped or to define an output name.

    If you have an equal problem, so here is the way i go:

    1.download source from svn: http://pdfbox.apache.org/downloads.html#scm and change the code as you like in this file:

    {PDFBOX-source-root}/pdfbox/src/main/java/org/apache/pdfbox/PDFSplit.java

    2.use maven to build your own PDFBox version: http://pdfbox.apache.org/building.html