[OS X TeX] Compressing pdf graphics
Chabot Denis
chabotd at globetrotter.net
Wed May 23 23:38:58 EDT 2007
Hi again,
Here is a summary of what I managed to learn from your many
suggestions so far, at least for solutions that required a single
operation: compressing an entire LaTeX-produced pdf document. My test
document is a report with 70 fairly large pdf figures (most are
around 300 KB). The pdf report is 20.6 MB.
My method up to now was to use Acrobat 7 Pro. In less than a minute,
I got a 6.6 MB pdf with all links functioning and no difference in
quality (that I could see, even zooming several levels). As mentioned
below, this requires Acrobat Reader version 6 or above (I chose this
setting when I selected "reduce file size in Acrobat) and makes the
document less compatible.
aarten Sneep and Guido Mocken recommended the use of pdftk for this
job. I tried and it is impressive: pdftk reduced it to 7.0 MB in
about the same time, not bad. All hyperlinks still functional.
"print-to-compressed-pdf" from Preview or Skim: produced a 10.7 MB
file (not too bad) but all hyperlinks broken (although the color was
preserved).
I tried PdfCompress, a demo of a commercial version (could not adjust
any setting, was set for "web" quality). I heard it degraded bitmaps
but since all my figures are vector graphics, the end product was 8.4
MB with no noticeable loss of quality and all links functional. Not
bad, but not better than free solutions (except drag and drop ease of
use).
I'll try to summarize later the many solutions that acted on each
individual graphic file, either shrinking each one with the tools
above or producing them as eps first with R (they tend to be smaller
than pdf) and then converting into pdf (sometimes huge saving
compared to pdf produced from R, sometimes very little saving,
depending on the type of plot).
Again, many thanks for the suggestions. Or course, it would be nice
if one or two lines added to a LaTeX file sufficed to compress the
final pdf (see my other post today).
Denis
> Subject: Re: [OS X TeX] Compressing pdf graphics
> From: "David Watson" <dewatson at mac.com>
> Date: Tue, 22 May 2007 19:31:16 -0500
>
> I don't have any idea how to compress within (La)TeX, but you might
> want to use the postscript output capability of R combined with the
> command-line utilities ps2pdf, ps2pdf12, ps2pdf13, or ps2pdf14
> provided with Ghostscript. Depending on your version of ghostscript,
> you can find some documentation on these at
>
> file:///usr/local/share/ghostscript/8.54/doc/Ps2pdf.htm
>
> (you may need to change the 8.54 to whatever version you have
> installed)
>
> I did a quick test on a simple plot and found some size advantages
> over the pdf() function in R.
>
> On May 22, 2007, at 12:14 PM, Chabot Denis wrote:
>
>> Hi,
>>
>> Recently I posted a question to the R mailing list because pdf
>> plots I make with it can be larger than png files when a lot of
>> objects are plotted (but offer much better quality, of course, in
>> particular for zooming in on details).
>>
>> What prompted my question was the fact that Acrobat can shrink
>> these graphics (or my LaTeX documents that contain lots of them)
>> quite a bit, and I was hoping there was a compression option I did
>> not know about.
>>
>> I'm including a reply I received because it suggests this
>> compression can be done within LaTeX.
>>
>> Do you know how to do this?
>
>
> ----------------------------------------------------------------------
>
> Subject: Re: [OS X TeX] Compressing pdf graphics
> From: "David Watson" <dewatson at mac.com>
> Date: Tue, 22 May 2007 19:36:11 -0500
>
> Sorry, I forgot to mention that you can get a better bounding box on
> your eps file by using epstopdf (an Apple utility). The size is about
> the same as the ps2pdf route.
>
> ----------------------------------------------------------------------
>
> Subject: Re: [OS X TeX] Compressing pdf graphics
> From: "David Watson" <dewatson at mac.com>
> Date: Tue, 22 May 2007 19:55:49 -0500
>
> I just discovered that you can achieve approximately identical
> results as epstopdf (Apple) using gs with
>
> ps2pdf -dEPSCrop myfile.eps
>
> In R, use something like
>
> postscript("myfile.eps", width=4.0, height = 3.0,
> horizontal=FALSE, onefile=FALSE, paper="special")
>
> to get the "eps" file.
>
> Perhaps someone else can assist you on the problem of including fonts
> families other than the standard Postscript fonts into your eps files.
>
>
>
>
> ----------------------------------------------------------------------
> Subject: Re: [OS X TeX] Compressing pdf graphics
> From: "Guido Mocken" <mocken at mpi-hd.mpg.de>
> Date: Wed, 23 May 2007 09:50:42 +0200
>
> Am 22.05.2007 um 22:40 schrieb Maarten Sneep:
>
>> pdftk [1] will compress pdf files for you, either the individual
>> graphics, or the final (pdflatex) output.
>
> This is definitely the way to go, because it is *lossless*
> compression. To be more precise:
>
> pdftk input.pdf output output.pdf compress
>
> I can compress my pdflatex-generated PHD thesis (which contains a lot
> of pictures) from 70 MB to just 7 MB this way without any loss of
> quality.
> Of course, I can achieve the same ratio using gzip or bzip2, but then
> the file can no longer be opened directly in a PDF reader.
>
> Guido
>
>
> ----------------------------------------------------------------------
> Subject: Re: [OS X TeX] Compressing pdf graphics
> From: "Victor Ivrii" <vivrii at gmail.com>
> Date: Wed, 23 May 2007 05:20:43 -0700
>
> On 5/23/07, Guido Mocken <mocken at mpi-hd.mpg.de> wrote:
>> Am 22.05.2007 um 22:40 schrieb Maarten Sneep:
>>
>>> pdftk [1] will compress pdf files for you, either the individual
>>> graphics, or the final (pdflatex) output.
>>
>> This is definitely the way to go, because it is *lossless*
>> compression. To be more precise:
>>
>> pdftk input.pdf output output.pdf compress
>>
>> I can compress my pdflatex-generated PHD thesis (which contains a lot
>> of pictures) from 70 MB to just 7 MB this way without any loss of
>> quality.
>> Of course, I can achieve the same ratio using gzip or bzip2, but then
>> the file can no longer be opened directly in a PDF reader.
>>
>> Guido
>>
>
>
> Note that one way to reduce size is using Acrobat and to require
> compatibility only with higher versions. However then it may become
> incompatible with the earlier versions of Acrobat; pretex compression
> can make it incompatible with TeX (the latest pdftex 1.40 accepts pdf
> <= 1.5 which corresponds to Acrobat 6)
>
>
> --
> ========================
> Victor Ivrii, Professor, Department of Mathematics, University of
> Toronto
> http://www.math.toronto.edu/ivrii
>
> ----------------------------------------------------------------------
>
> Subject: Re: [OS X TeX] Compressing pdf graphics
> From: "Maarten Sneep" <maarten.sneep at xs4all.nl>
> Date: Wed, 23 May 2007 19:48:03 +0200
>
> On May 23, 2007, at 02:55, David Watson wrote:
>
>> I just discovered that you can achieve approximately identical
>> results as epstopdf (Apple) using gs with
>
> epstopdf is a perl script that uses ghostscript (which is used by
> ps2pdf as well).
> pstopdf is the Apple command line tool that converts postscript to
> pdf (the same tool used by preview, and actually the Adobe distiller
> with sane but fixed parameters).
>
> Maarten
>
>
> ----------------------------------------------------------------------
>
> Subject: Re: [OS X TeX] Compressing pdf graphics
> From: "Nestor Aguilera" <aguilera at ceride.gov.ar>
> Date: Wed, 23 May 2007 18:45:07 -0300
>
>
> On 23 May, 2007, at 14:48, Maarten Sneep wrote:
>
>> epstopdf is a perl script that uses ghostscript (which is used by
>> ps2pdf as well).
>> pstopdf is the Apple command line tool that converts postscript to
>> pdf (the same tool used by preview, and actually the Adobe
>> distiller with sane but fixed parameters).
>
> In my MacBook, Preview, eps2pdf and epstopdf produce quite different
> results. Applied to a particular .ps file, and then looking for File -
>> Properties in Acrobat Reader, I see
>
> with producer PDF
> version size
> Preview Mac OSX 10.4.9 Quartz PDFContext 1.3 (Acrobat
> 4.x) 364 KB
> ps2pdf GPL Ghostscript 8.54 1.3 (Acrobat
> 4.x) 168 KB
> pstopdf Apple pstopdf 1.3 (Acrobat
> 4.x) 264 KB
>
> It seems that the the output of pstopdf is the cleanest: I can search
> for strings (and find them), but not for the other two.
>
> Best,
>
> Nestor
>
> ----------------------------------------------------------------------
------------------------- Helpful Info -------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/
List Reminders & Etiquette: http://www.esm.psu.edu/mac-tex/list/
More information about the MacOSX-TeX
mailing list