Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 08-27-2004, 06:16 AM   #1
Senior Member
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Rep: Reputation: 58
Ghostscript: why is pdf size sometimes increased so much?

I had two pdf files each of size 100k, containing scanned images.
Those pdfs were probably created by Adobe Acrobat.

I merged them with ghostscript, as follows:

gs -dNOPAUSE -sDEVICE=pswrite -dBATCH 1.pdf
gs -dNOPAUSE -sDEVICE=pswrite -dBATCH 2.pdf
gs -dNOPAUSE -sDEVICE=pswrite -dBATCH
gs -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=merged.pdf -sProcessColorModel=DeviceGray -sBitsPerSample=1 -dCompressPages=true -dBATCH

The problem is that the resulting file (merged.pdf) is about 15 times as big as it should be (3M instead of 200k), and, maybe because of this, it is very-very slowly rendered on the screen by acroread.

The result is about the same either with or without the ProcessColorModel, BitsPerSample and CompressPages options, which I tried to use to reduce file size.

Strangely, I found that the -r option of gs can only grow file size (-r60 resulted in a cca. 1.5 times larger file).

I wonder what is wrong with those pdf files (or with ghostscript), that they become so large when extracted to ps and re-encoded to pdf?

Last edited by J_Szucs; 08-27-2004 at 06:26 AM.
Old 08-27-2004, 07:56 AM   #2
Senior Member
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
PostScript is an interpreted language, where everything on the page is divided into a number of different drawing instructions that get processed to build up the page. I believe that PDF is similar (but I may be wrong).

I suspect that what's happening is that the conversion to PS takes each PDF instruction and converts it into a number of different postscript instructions, and the conversion back to PDF takes each PS instruction and converts it into several PDF instructions.

You might try writing the output file to postscript and using the ps2pdf utility to convert it, which has a number of options to control how the processing works, and what optimisations are done etc.

Hope that's of some help,

Robert J. Lee
Old 08-27-2004, 09:19 AM   #3
Senior Member
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Original Poster
Rep: Reputation: 58
I think that ps2pdf actually calls gs to do the conversion in a way that any option to ps2pdf that affects the resulting pdf file is simply passed to gs.
So, those options are actually the options of gs, which I carefully checked.

I suspect that my problem may rather be related to the fact that the pdfs to be merged are of pdf version 1.4, which pdf version my gs 7.04 can only read, but cannot write, so, maybe it writes in pdf version 1.3, which cannot compress the contents so efficiently. (just realised that I have no such problem with pdf files up to version 1.3)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ghostscript & pdf mania arunswarup General 0 11-07-2005 01:45 PM
increased reiserfs partition size lobo78 Linux - General 1 06-18-2005 10:54 AM
Wow, My Yahoo Mail account has increased in size jaz General 13 09-01-2004 07:28 AM
What is wrong with pdf files created by Ghostscript? J_Szucs Linux - Software 2 02-01-2004 09:45 AM
Ghostscript and pdf creation J_Szucs Linux - Software 0 05-29-2003 02:55 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:48 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration