1

I'm running Kubuntu 18.04. I want to extract page 10 from a PDF file in the form of another PDF file. The program qpdf is supposed to do that. When I run the command

qpdf 0092434747.pdf --pages . 10 -- - > mtg.pdf

it seems to do the extraction, but there's no output; the file mtg.pdf is not created. I get the same result with (the more straightforward command)

qpdf 0092434747.pdf --pages . 10 -- mtg.pdf

What am I missing?

3
  • Have you tried it without the redirect? From the docs, this is an example to get pages 1-5: qpdf infile.pdf --pages . 1-5 -- outfile.pdf Dec 26, 2020 at 3:01
  • You can also have a look at pdftools (disclaimer: I am the author of it) Dec 26, 2020 at 3:03
  • Both your command lines work for me, and the second matches @ajgringo619's comment. Try adding --verbose to the second one? Try page 1?
    – skierpage
    Mar 21, 2023 at 3:15

4 Answers 4

3

The magic combination of options is qpdf --empty --pages infile.pdf 1-5 -- outfile.pdf.

1

On Ubuntu I use Evince for PDFs, and I use the normal print dialog for extracting pages. In the printer selection, I have an option "Print to file". Then there is the field where I can enter which pages I want to be "printed". The result is a saved .pdf file.

0

Both your command lines should work, try adding --verbose to the second one (qpdf --verbose 0092434747.pdf --pages . 10 -- mtg.pdf) to see why it's failing. They name a primary input file, so as the qpdf docs say "Document-level information, such as outlines, tags, etc., is taken from the primary input file". A 'dot' works as a file name because "You can use . as a shorthand for the primary input file, if not empty,"

If you don't want any document information from your input file, you can start with an empty file and select page(s) from your input file:

qpdf --empty --pages infile.pdf 10 -- outfile.pdf

Be careful, qpdf will overwrite existing files without warning, so work with a copy of your file(s) unless you're sure what you're doing.

0

pdftk

For your case would be pdftk input.pdf cat 10-10 output output.pdf.

# tldr:pdftk
# pdftk
# PDF toolkit.
# More information: <https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit>.

# Extract pages 1-3, 5 and 6-10 from a PDF file and save them as another one:
pdftk input.pdf cat 1-3 5 6-10 output output.pdf

# Merge (concatenate) a list of PDF files and save the result as another one:
pdftk file1.pdf file2.pdf ... cat output output.pdf

# Split each page of a PDF file into a separate file, with a given filename output pattern:
pdftk input.pdf burst output out_%d.pdf

# Rotate all pages by 180 degrees clockwise:
pdftk input.pdf cat 1-endsouth output output.pdf

# Rotate third page by 90 degrees clockwise and leave others unchanged:
pdftk input.pdf cat 1-2 3east 4-end output output.pdf

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .