使用 qpdf 将一个 PDF 文件拆分为另外两个 PDF 文件

Split a PDF file into another two PDF files using qpdf

是否可以使用 qpdf 工具将 PDF 文件拆分为两部分或 n 部分?

文档是这么说的,但我找不到执行此操作的确切命令。

我使用的是 qpdf 版本 10.0.1。

一种有点野蛮的处理方式,可以通过 修改大文件并输出 = 然后 re-running 全部更新为多个文件的子集。 一旦我为它做了适当的功能就会更新。

pacman::p_load(pdftools, qpdf)
#some prep
bigfile <- "Some/File/Path.pdf"
biginfo <- pdf_length(bigfile)

# now we subset x2 being sure to define unique names for output
# otherwise the second file will overwrite the first one we create here.
# for part 1
pdf_subset(bigfile,
           pages = 1:(biginfo/2),
           output = "Some/File/Path_part_1.pdf")
# for part 2
pdf_subset(bigfile,
           pages = ((biginfo+1)/2):biginfo,
           output = "Some/File/Path_part_2.pdf")

是的,很简单:

假设 infile.pdf 有 12 页(页数):

qpdf.exe --split-pages=n infile.pdf output-%d.pdf

伪代码:

n = 整数(页数 / number_of_parts)

来自原始文档的更多详细信息:

--split-pages=[n]

Write each group of n pages to a separate output file. If n is not specified, create single pages. Output file names are generated as follows:

If the string %d appears in the output file name, it is replaced with a range of zero-padded page numbers starting from 1.

Otherwise, if the output file name ends in .pdf (case insensitive), a zero-padded page range, preceded by a dash, is inserted before the file extension.

Otherwise, the file name is appended with a zero-padded page range preceded by a dash.

Page ranges are a single number in the case of single-page groups or two numbers separated by a dash otherwise. For example, if infile.pdf has 12 pages

qpdf --split-pages infile.pdf %d-out would generate files 01-out through 12-out

qpdf --split-pages=2 infile.pdf outfile.pdf would generate files outfile-01-02.pdf through outfile-11-12.pdf

qpdf --split-pages infile.pdf something.else would generate files something.else-01 through something.else-12

参考:http://qpdf.sourceforge.net/files/qpdf-manual.html#ref.basic-options