7

Do you know a possibility how to export a PDF, that has just blank space where the graphics should be? (And the other way round)

Why do I need this? I have a black and white laser printer and an inkjet printer.

I would love to use the black and white laser printer for the text, take the printed paper and put it in the inkjet printer to get perfect colorful pictures in my printings.

Or is there a other possibility?

Kurt Pfeifle
  • 3,791
TimK
  • 703

1 Answers1

5

So you want to

"...know a possibility how to export a PDF, that has just blank space where the graphics should be? (And the other way round)"

Well, I don't know how to reach that point directly. But I know a detour with three backdoors which get you were you want:

  1. First, the detour: Export to PDF just as normal. The result will be no blank space where the graphics should be. No, there will be a graphics where the graphics should be. And text plus vectors where text plus vectors should be...

  2. Second, the first backdoor: Make sure you have a Ghostscript version v9.16 or newer installed. Then run:

    gs -o onlytext.pdf -sDEVICE=pdfwrite -dFILTERIMAGE -dFILTERVECTOR input.pdf
    

    The -dFILTERIMAGEparameter will remove all raster images from your PDF. The -dFILTERVECTOR param will remove all vector drawings or other line art from your PDF. What remains are all the textual components on all pages.

  3. Third, the second backdoor: Use the same Ghostscript and run:

    gs -o onlyimage.pdf -sDEVICE=pdfwrite -dFILTERTEXT -dFILTERVECTOR input.pdf
    

    The -dFILTERTEXTparameter will remove all text parts from your PDF. The -dFILTERVECTOR param you're already familiar with.... What remains are the raster image components on all pages.

  4. Fourth, the third backdoor: Again, run Ghostscript:

    gs -o onlyvector.pdf -sDEVICE=pdfwrite -dFILTERTEXT -dFILTERIMAGE input.pdf
    

    You guess what this does? What remains are only the vector components on all pages.

Of course, you could also use only one of the params to remove one of the element types from the PDF and retain the other two.


Example output

Here is an example document which I use to demo the options. Admittedly, the document wasn't created with LaTeX, so bear with me...

Screenshot of original PDF page containing "image", "vector" and "text" elements.
Screenshot of original PDF page containing "image", "vector" and "text" elements.

Running the following 6 commands will create all 6 possible variations of remaining contents:

 gs -o noIMG.pdf   -sDEVICE=pdfwrite -dFILTERIMAGE                input.pdf
 gs -o noTXT.pdf   -sDEVICE=pdfwrite -dFILTERTEXT                 input.pdf
 gs -o noVCTR.pdf  -sDEVICE=pdfwrite -dFILTERVECTOR               input.pdf

 gs -o onlyTXT.pdf -sDEVICE=pdfwrite -dFILTERVECTOR -dFILTERIMAGE input.pdf 
 gs -o onlyIMG.pdf -sDEVICE=pdfwrite -dFILTERVECTOR -dFILTERTEXT  input.pdf
 gs -o onlyVCT.pdf -sDEVICE=pdfwrite -dFILTERIMAGE  -dFILTERTEXT  input.pdf

The following image illustrates the results:


Top row, from left: all "text" removed; all "images" removed; all "vectors" removed. Bottom row, from left: only "text" kept; only "images" kept; only "vectors" kept.
Top row, from left: all "text" removed; all "images" removed; all "vectors" removed. Bottom row, from left: only "text" kept; only "images" kept; only "vectors" kept.


Kurt Pfeifle
  • 3,791
  • Thank you very much for your detailed answer and for showing a backdoor approach!

    It is a interesting way and I tend to accept your answer (as it does not seem to me that there will be any better options soon). Except the only "problem" I see are the areas with mixed content (the plot). The labels are "over" the text. I would print laser first and the second "print" would be inkjet. Inkjet has problem sticking on laser toner, the other way round is better, but not ideal.

    So there's probably no way of removing the labels from the graph without changing their type, or is there?

    – TimK Jan 02 '19 at 16:45
  • 1
    @TimK: whether there are areas where any two of the three base components (text, pixelgraphics and vectors) are mixed and overlayed onto each other is totally dependent on the software which generated the PDF file and on the author who designed the original document. My demo example at the time was made with a random file (actually, one made for another demo purpose) I had just handy. But it shows what could occur in real life. And no, you'll very likely not see any better options coming up soon. – Kurt Pfeifle Jan 02 '19 at 17:48