PDF file compression by opensource


There is a requirement to reduce the PDF file size of 47MB by open source tool.

The options I come across

1. Ghost script:

Installed ghost script by $sudo apt-get install ghostscript and tried the below command

$gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

dPDFSETTINGS=/screen —> in this syntax there are various method of compression tools available like /printer instead of /screen for the size variation according to the requirement.

But this never works to me and also corrupts the source file.

2. PDFTK:

Installed pdftk by $sudo apt-get install pdftk and tried the below command

$pdftk file1.pdf output file2.pdf compress

The size remain unchange (same 47MB)

 

3. I tried to convert the pdf file to ps and PS to pdf. It works !!!

The syntax is

$pdf2ps  file1.pdf   file1.ps

$ps2pdf  file1.ps   file2.pdf

The size reduced from 47 MB to 2MB.

This is a simple option and nevertheless to worry about ghostscript syntax.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: