CPDF - command line PDF tools

Submit command line tools that you find here.
Post Reply
Message
Author
billon
Posts: 842
Joined: Sat Jun 23, 2012 4:28 pm

CPDF - command line PDF tools

#1 Post by billon »

[Moderator note: this thread was split from the ImageMagick thread.]

---
Midas wrote:Now, something to do the same to PDF files would be the works
Try cpdf

User avatar
Midas
Posts: 6905
Joined: Mon Dec 07, 2009 7:09 am
Location: Sol3

Re: ImageMagick - command line image conversion

#2 Post by Midas »

billon wrote:Try cpdf
Thanks for the tip. Will do. 8)

User avatar
__philippe
Posts: 689
Joined: Wed Jun 26, 2013 2:09 am

Re: ImageMagick - command line image conversion

#3 Post by __philippe »

@billon

Seconded, ta for the cpdf pointer !
This recent (March 2017) cpdf user manual might prove handy as well :wink:

User avatar
webfork
Posts: 10836
Joined: Wed Apr 11, 2007 8:06 pm
Location: US, Texas
Contact:

Re: CPDF - command line PDF tools

#4 Post by webfork »

Great post billon and __philippe. I'm almost certainly going to post more about this tool so I decided to go ahead and split off from ImageMagick to avoid a thread hijack.

Program is cross-platform (mac/win/linux), supports strong encryption, and lossless compression.

License: Free for non-commercial use, code used by this program bound by the same license: https://github.com/coherentgraphics/cpd ... er/LICENSE ... buy a license here: http://www.coherentpdf.com/ for around $340 USD (as of this writing).

User avatar
webfork
Posts: 10836
Joined: Wed Apr 11, 2007 8:06 pm
Location: US, Texas
Contact:

Re: CPDF - command line PDF tools

#5 Post by webfork »

I did a bit more digging and it looks like they add a watermark to all processed pages so it looks like this program is really just a demo for a commercial product, save for listing fonts or reading document info.

https://www.coherentpdf.com/eval.html

I'm disappointed but certainly not surprised. This is a very powerful toolset.

User avatar
webfork
Posts: 10836
Joined: Wed Apr 11, 2007 8:06 pm
Location: US, Texas
Contact:

Re: CPDF - command line PDF tools

#6 Post by webfork »

It doesn't have anywhere near the features but PDFBox is a Java-based alternative to CPDF https://pdfbox.apache.org/index.html that might be portablized using jPortable and the companion JAR Launcher.

User avatar
webfork
Posts: 10836
Joined: Wed Apr 11, 2007 8:06 pm
Location: US, Texas
Contact:

Re: CPDF - command line PDF tools

#7 Post by webfork »

Another one to add to the list of CLI PDF tools: http://www.xpdfreader.com/ / https://www.softpedia.com/get/Office-to ... Xpdf.shtml based on

Tools include:
xpdf: PDF viewer
pdftotext: converts PDF to text
pdftops: converts PDF to PostScript
pdftoppm: converts PDF pages to netpbm (PPM/PGM/PBM) image files
pdftopng: converts PDF pages to PNG image files
pdftohtml: converts PDF to HTML
pdfinfo: extracts PDF metadata
pdfimages: extracts raw images from PDF files
pdffonts: lists fonts used in PDF files
pdfdetach: extracts attached files from PDF files

billon
Posts: 842
Joined: Sat Jun 23, 2012 4:28 pm

cpdfsqueeze - lossless PDF compressor

#8 Post by billon »

https://community.coherentpdf.com/
Now we're releasing {...} a lossless PDF squeezer under the LGPL.

https://github.com/coherentgraphics/cpd ... e-binaries
Cpdfsqueeze is a lossless compressor for PDF files, which works by rearranging and coalescing content within the file.
Windows32bit
Windows64bit

User avatar
webfork
Posts: 10836
Joined: Wed Apr 11, 2007 8:06 pm
Location: US, Texas
Contact:

Re: cpdfsqueeze - lossless PDF compressor

#9 Post by webfork »

billon wrote: Thu Mar 19, 2020 3:13 am Cpdfsqueeze is a lossless compressor for PDF files, which works by rearranging and coalescing content within the file.
Excellent, I'll test this out very soon.

EDIT: Looks like this just got included in the latest version of FileOptmizer so I can test it out even sooner :)

User avatar
Cornflower
Posts: 246
Joined: Fri Aug 31, 2007 7:58 am
Location: Canada's capital

Coherent PDF: cpdf and cpdfsqueeze

#10 Post by Cornflower »

With version 2.3 (December 2019) Coherent has given its cpdf a non-commercial use license. I used cpdf commercially at work, and am glad I can use it at home not, too.

cpdf is a PDF toolkit, capable of everything pdftk does, and much more. Examples include
Merge PDF files together, or split them apart
Encrypt and decrypt
Scale, crop and rotate pages
Pad pages, put multiple pages on each page
Read and set document info and metadata, font management
Copy, add or remove bookmarks
Stamp logos, text, dates, page numbers
Add or remove attachments
Losslessly compress PDF files

You will want to use the 72-page manual for the over 100 possible options.

cpdfsqueeze simply produces a lossless compression of a pdf file. This functionality is also in cpdf.

Homepage: https://community.coherentpdf.com/
Download cpdf: https://github.com/coherentgraphics/cpd ... master.zip
Download cpdfsqueeze:https://github.com/coherentgraphics/cpd ... master.zip

cpdf Manual:http://www.coherentpdf.com/cpdfmanual/cpdfmanual.html or download as PDF http://www.coherentpdf.com/cpdfmanual.pdf

Non-commercial use License: https://github.com/coherentgraphics/cpd ... er/LICENSE

Runs on Vista and above.
Use Cases: PDF manipulation
Category: PDF Processing

I will submit to the database as soon as I read up on the submission fields I am not sure I understand.

User avatar
juverax
Posts: 399
Joined: Mon Jun 11, 2018 5:19 am

Re: CPDF - command line PDF tools

#11 Post by juverax »

Only recently I tried to test Coherent PDF, in short cpdf (downloaded from the current github page) on my Windows 10 (64 bits, of course).
I could not get it to run, neither the cpdf 32 nor the cpdf 64.

All I got was something like .... You system does care of 16 bit Apps (just kidding, see attachment).
CoherentPdf=16Bit_Application.jpg
CoherentPdf=16Bit_Application.jpg (17.68 KiB) Viewed 2440 times
Since I was definitely interested in shrinking PDFs, I had to resort to similar tools, and the first I tried was:
FileOptimizer, in the DataBase: https://www.portablefreeware.com/index.php?id=2377

!!!! Jack Pot !!!! : Coherent PDF is actually embedded in FileOptimizer. In the installation folder, go to App >> FileOptimizer >> Plugins64 (or Plugins32 ... depends on your machine) ... and cpdf is right here!

If cpdf is all that you need, just copy it to a folder where you can use it as a command line tool on you "big fat pdf".

In console mode run:
cpdf -squeeze in.pdf -o out.pdf (in.pdf is the name of your input file, out.pdf is the name you want cpdf to copy your shrunk file).

Done! Well, Not so fast!!! Now let's see how many MB I saved on my hard drive ....
Size of my original file: 276, 991, 541
Size of the shrunk file: 276, 732, 124
FileOptimizer_CompressionRate.jpg
.

As of this writing, the only more efficient way to shrink a pdf is to reduce the margins (white space around the text content of text page in the case you are working with a scanned document.

IrfanView does exactly that, and very easily:
======================================

C:\irfn\i_view32.exe C:\infiles\*.tif /crop=(x1,y1,x2,y2) /aspectratio /resample /tifc=4 /convert C:\outfiles\*.tif

Note1: Have a folder where you place irfanview (here: irfn)
Note2: Have a folder where you place your input files (here infiles)
Note3: Have a folder where you place the above line of code in a text file that you can name shrink.txt., that you then rename shrink.bat
You name the folder whateveryou like, e.g. outfile.

How to determine x1, y1, x2, y2 .
Personally I use Microsoft Paint because it shows you the coordinates of the mouse pointer.

Note 4: It is straightfoward to determine x1 and y1
Note 5: It is more tricky to determine x2 and y2
Actually x2 = x of the cursor minus x1
y2 = y of the cursor minus y1

Note 6: Now you can rename shrink.txt >> shrink.bat
Note 7: IrfanView works with many file formats, not exclusively TIFs

Ready to go: clink on shrink.bat and the resulting files will be stored in the outfiles folder.

Post Reply