Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Say I have a PDF of a website which is very long. After reading some of it, I decide there are extraneous pages in it; but rather than finding the website every time I decide to eliminate a page, I want to print it to PDF and just not select that page to print (using CUPS-PDF). Will this degrade the quality of the PDF, particularly if I were to do it multiple times? Is there a better way to achieve what I am looking for? I have tried PDFEdit, with mixed results, and would like something more reliable. Of course, I can always just go back to the site and save a new version, using the same technique of neglected those pages that I don't want.

share|improve this question
1  
a) Why don't you just save the pdf as pdf, and read it when you like to? b) Why not just test, how it changes, after printing it multiple times to pdf? Please tell us your observations later here. –  user unknown Sep 17 '11 at 3:42
    
@user unknown I tested it with a PDF that had text and images, but no other special features that I am aware of. I the "Print to File" that seems to be builtin to Gnome (I did it in Evince). (So I did not end up trying it with CUPS-PDF, tho I have that installed.) None of the visual quality seems to have been degraded after one save, and I can still select text. However, when I copy it, the text is corrupted. Example: "Schrödinger Wave Function" comes out like this: 􀀗􀀚􀀑􀀍􀁂􀀋􀀓􀀊􀀘􀀈􀀍􀀆􀀕􀀎􀀝􀀈􀀆􀀯􀀄􀀊􀀚􀀅􀀓􀀃􀀊 –  Kazark Sep 17 '11 at 17:07
    
CUPS has a pdftopdf utility but no details how to use it, not to be confused with Ghostscript's pdf2pdf. –  Steve-o Sep 23 '11 at 21:07

3 Answers 3

up vote 10 down vote accepted

In principle, it is possible to print a PDF through some chain of programs that ends in a PDF generation with no quality loss.

Two major things have to happen to guarantee a perceptually lossless conversion:

  1. Every link in the chain has to understand all of the document elements, and be able to pass them along to the next piece in the chain losslessly:

    • If the document contains embedded fonts, the font must also be installed somewhere the PDF writer can find it so it can re-embed it, or the embedded font has to somehow be passed through the chain.

    • If the document contains embedded applets — JavaScript, Flash, Postscript... — they have to be passed along untouched.

    • If the document contains hyperlinks, active forms, OCR text layers, custom page numbering, non-printing markup, comments, metadata, etc., all the pieces along the chain have to know how to pass this data through to the writer.

    • If the document contains mixed page sizes, the programs in the chain have to be capable of that trick, too.

  2. No link in the chain may reinterpret any data passing through it. It is common in PDF chains for images to be resampled and converted to more efficient lossy formats, for example. Even if the images in your original PDF are already low-DPI JPEGs, the pieces in the chain might choose a different DPI or have a different compression level setting.

    (By the way, the mere fact that there is a JPEG on either or both ends of the PDF-to-PDF chain technically means the chain is not lossless, unless the raw JPEG data is being passed through as-is somehow. However, it is possible for a recompression step to be perceptually lossless. This does not always happen, however, sometimes on purpose.)

So far, I've considered only perceptual quality. It is possible to achieve a perceptually lossless conversion but lose editability or end up with a substantially larger file:

  • A PDF document containing text which was created from a primary source (that is to say, not a scan or conversion from some other document presentation format) usually contains the actual text and font data that lets the PDF reader draw the text on the screen in the same way a word processor does.

    It is possible to turn such text into 2D raster or vector art in a perceptually lossless fashion. PDF even allows you to preserve searchability and screen reader accessibility by use of non-printing OCR text layers. However, such a conversion would balloon the file size and make editing much more difficult.

  • Vector art may be rasterized, using DPI equal to or an even multiple of the print/viewing DPI.

  • The chain could convert all JPEGs to TIFFs, so as to lose absolutely no image quality.

  • The chain could involve JPEG to JPEG, with no DPI change, but use a high fixed quality setting so as to avoid creating perceptible artifacts.

For your simple case, deleting a page, it is fairly easy to get a no-loss guarantee, if you use a program that understands the PDF file format well enough to simply elide the page data. This is completely doable, since pages in PDF more or less stand alone. It's just a question of finding a tool that knows enough about the particular PDF variant your existing files are encoded with. PDF is a very complex file format, so it is common for programs claiming to support PDF to have only partial support in actual fact. It may be that that there is only one program that truly understands 100% of PDF: Adobe Acrobat Pro. It would not surprise me to learn that every single other program that deals with PDF is actually speaking a subset.

Bottom line, I would not expect a PDF-via-print-from-PDF chain to give such quality guarantees. There's just too much opportunity for interpretation and intermediation.

share|improve this answer

If I understand your main goal correctly, you don't need to go through any hassle with printing to PDF. You can use a command-line tool like pdftk to extract any set of pages directly from a PDF file and save them as a new one. (It also allows many more operations like optimizing, adding/removing password, rotating some pages, etc.) The tool is available in package repositories of (probably) all desktop Linux distributions.

The main pdftk operation you would use is cat. It works quite intuitively—for example:

pdftk input_file.pdf cat 3-23 50-end output output_file.pdf

will create a file output_file.pdf composed of pages 3 through 23 and 50 through the end of the original input_file.pdf file. Look into man pdftk for more examples (at the end of the manual).

share|improve this answer
1  
Thanks; not answering the question itself, but certainly providing very valuable information and addressing the problem behind the question. Will upvote when I get enough reputation... –  Kazark Sep 16 '11 at 23:16

In general, no, quality loss should not occur. If it does, the program is to blame, not the format. Some things that could occur that could be construed as quality loss:

  • Images may be recompressed (potentially causing generation loss)
  • Text (and other vectors) may be turned into splines, potentially causing usability issues (inability to copy text) etc

I have never used CUPS-PDF or PDFEdit, so these are merely suppositions about what may occur, that is, I don't know if it is likely that they will or not.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.