LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 08-27-2004, 07:16 AM   #1
J_Szucs
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 -sOutputFile=1.ps -dBATCH 1.pdf
gs -dNOPAUSE -sDEVICE=pswrite -sOutputFile=2.ps -dBATCH 2.pdf
gs -dNOPAUSE -sDEVICE=pswrite -sOutputFile=merged.ps -dBATCH 1.ps 2.ps
gs -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=merged.pdf -sProcessColorModel=DeviceGray -sBitsPerSample=1 -dCompressPages=true -dBATCH merged.ps

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 07:26 AM.
 
Old 08-27-2004, 08:56 AM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

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, 10:19 AM   #3
J_Szucs
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)
 
  


Reply


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 02:45 PM
increased reiserfs partition size lobo78 Linux - General 1 06-18-2005 11:54 AM
Wow, My Yahoo Mail account has increased in size jaz General 13 09-01-2004 08:28 AM
What is wrong with pdf files created by Ghostscript? J_Szucs Linux - Software 2 02-01-2004 10:45 AM
Ghostscript and pdf creation J_Szucs Linux - Software 0 05-29-2003 03:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

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