4

I would like to compress PDF files in my Node.JS application which will be generated by electron. I tried to compress these files with Ghostscript which worked fine btw but I cannot use this commercially without paying for it.

Is there any good command line based solution alternative free for commercially use?

PS: I already tried compressing with LibreOffice Draw, but this cant handle included fonts :/

ponsfrilus
  • 586
  • 1
  • 5
  • 15
user547995
  • 101
  • 1
  • 1
  • 8
  • 1
    What makes you believe that you can't legally use Ghostscript on your web server for commercial purposes? According to `/usr/share/doc/ghostscript/copyright` it's licensed with a combination of AGPL v3, BSD 3-clause, GPL v2, GPL v3, LGPL v2.1 and Apache 2.0 all of which allow you to use it on a web server for any purpose free of charge (as long as you publish any changes that you make to the code base in the case of AGPL). I'd vote to close as unclear if that were possible with the open bounty. – David Foerster Aug 09 '17 at 13:46

2 Answers2

2

You can use pdftk to compress a pdf using the following command

pdftk file1.pdf output file2.pdf compress

To this first, you need pdftk installed on you computer, install it by typing

    sudo apt-get update
    sudo apt-get install pdftk
  • I already tried pdftk, which needs a commercial licence as well – user547995 Aug 08 '17 at 10:09
  • specialised fonts will always be a problem in compressing pdf, even Ghostscript cannot compress with all fonts. you will have to do it via trial and error method. there are several apps in repos pdfsam, gscan2pdf, scantailor. try and see if anything helps you – techvish81 Aug 09 '17 at 05:55
1

What I got from this link is that you can use ghostscript in you application if you're going to use it as a library (i.e. you won't copy the source code of ghostscript into your own source code).

Even if you're going to modify ghostscript and use that modified version as a library, you will only have to make the source code of the modified ghostscript available.

Johnny Bravo
  • 111
  • 6