6

I have a niche Java app that I use extensively (since it's Java and thus basically cross-platform, and since it can cater to my needs), and its job is to produce a printed page with text on it.

However, I need to distribute those printed pages electronically, and thus I installed the printer-driver-cups-pdf package, which gives me a PDF printer, and thus I can distribute PDF's to my team members.

However, these "printed" PDF's are enormous. A 2-page PDF is easily 800kb, and three pages are well over 1MB. This is a problem, since I cannot easily e-mail 10 of these documents to someone quickly.

Exporting a page with around the same amount of text within LibreOffice results in PDF files at least 10 times smaller.

Does anyone have any suggestions?

I cannot use image compression, since these pages contain only vectors.

Incidentally, I am using Ubuntu 15.10.

Thanks in advance!

EDIT: I have already tried Ghostscript with various -dPDFSETTINGS=/ settings. That, however, does not work, since it only applies to raster images. I have also tried converting to/from SVG, PS and EPS. I am still stuck with preposterously huge vector PDF files.

etsnyman
  • 1,125
  • IIRC you don't need to use the CUPS PDF printer. There should be a save to file option in the print dialog anyway. – muru Mar 08 '16 at 12:53
  • @muru That depends on how the program handles the printing, I would not assume that. – FatalMerlin Mar 08 '16 at 12:58
  • @muru Unfortunately, because this is a Java app, it uses a Java print dialog, which has no Save-To-File option. I am still stuck with printer-driver-cups-pdf ... – etsnyman Mar 08 '16 at 12:58
  • Maybe you could try adjusting the CUPS PDF resolution via the CUPS web interface (https://localhost:631), or use Ghostscript or something to compress the PDF: http://askubuntu.com/q/113544/158442 – muru Mar 08 '16 at 13:02
  • 1
    @MeerLin can we just delete these off-topic comments? – muru Mar 08 '16 at 13:18
  • Is your Java program open source by any chance? A workaround might be to edit the program to write the output to a file instead of printing it. – FatalMerlin Mar 08 '16 at 13:53
  • @MeerLin I wish it was. Some people are looking into creating open-source alternatives, but those could be months or years away... :-( – etsnyman Mar 08 '16 at 14:02
  • http://superuser.com/questions/401176/reducing-the-file-size-of-pdfs-generated-with-cups-pdf – You'reAGitForNotUsingGit Feb 11 '17 at 15:58

2 Answers2

3

cups-pdf has been broken for a long time. It produces very large PDF files that encapsulate images and do not support text selection (for copy-paste).

A decent alternative is the Tea4CUPS virtual printer.

It works well most of the time for me, but sometimes printing with Tea4CUPS will abort -- in those cases, I resort to the Ubuntu built-in Print to File option.

pvillela
  • 191
0

Maybe ghostscript can help you compress your PDFs, as it will reduce their size and also optimize them for viewing them on screen rather than on paper:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen \
-dNOPAUSE -dQUIET -dBATCH -sOutputFile=out.pdf in.pdf

Alternatively maybe the answers to this question might be helpful.

  • Unfortunately, for reasons unknown to me, because these files contain only vectors, the new files that ghostscript creates are even larger. Sorry, but I did try that... – etsnyman Mar 08 '16 at 13:04
  • @etsnyman Did you have a look on the link I provided? – FatalMerlin Mar 08 '16 at 13:05
  • Yes, I have looked. Everything there seems to compress/optimize rasters, not vectors. – etsnyman Mar 08 '16 at 13:07
  • @etsnyman mention what you have tried in the question, then. – muru Mar 08 '16 at 13:15
  • @muru I did specifically mention that I cannot use image compression as it will not work. I didn't feel like listing the 5-6 different options I have tried. – etsnyman Mar 08 '16 at 13:21
  • @etsnyman mention them anyway. Nobody cares what you feel. You want us to help, we don't want to waste time suggesting things you have already tried. – muru Mar 08 '16 at 13:22