Tag Info

Hot answers tagged

57

There are a number of tricks for getting optimized pdfs. Many of them are implemented in the tool pdfsizeopt. With some patches (posted in the pdfsizeopt bugtracker) this tool can run on all my tex-generated pdfs (and nearly all of the non-tex-generated ones). I use the commandline: python ./pdfsizeopt.py --use-pngout=true --use-jbig2=true ...


54

A common approach is to let Ghostscript (gs) optimize and compress the PDF after it has been created with pdflatex. Ghostscript is installed by most Linux distributions and easily available for other platforms (Windows as binaries, MacOS via MacPorts). In fact, almost all size-optimizing tools for PDF (save for Acrobat) you can find on the internet, ...


50

MacTeX (and by extension TeX Live) are so big because they contain everything up to, and including the kitchen sink, then heaps on yet more stuff. Odds are, out of that 1.3 GB archive you will only use 300-400 MB worth of files on a regular basis. This is similar in size to an application like OpenOffice. There is an alternative to downloading and ...


24

Here is my version of an improved pdfcrop. Default operation is to remove white margins from the pdf input, optionally leaving a user defined extra-margin (option -m ...). Alternative operation is to trim the page edges by user defined amounts (option -t ...). pdfcrop.sh uses gs for page-wise determination of the tightly enclosing bounding box, pdftk for ...


19

Martin Heller has stated the correct answer: dvipdfm uses a different font format than pdftex. You can look into the PDF file by loading it into a text editor. Sometimes (well, often), the objects are compressed and you only see some data. So you either need a decompression algorithm built into your head, or use a tool like qpdf to uncompress the objects ...


19

Update: The current proTeXt actually contains TeXstudio as an editor, and not TeXnicCenter anymore, but that information hasn't even reached all of their own web sites yet. proTeXt is a bundle that contains, among other things, MiKTeX, which is one of the two major TeX distributions (the other being TeX Live): First, proTeXt adds a few independent ...


18

If for some reason you don't want to use pdfsizeopt: both XeTeX and LuaTeX typically generate smaller PDF files than pdfTeX because OpenType fonts are already encoded in either CFF or TrueType outlines.


17

The elephant in the room are the embedded bitmaps, which can blow up the file size really fast. I have a 400 page book manuscript with lots of molecular structures rendered at 600 dpi (for print), and the overall file size is 50 Mb. I just googled around for a way to reduce the resolution of embedded images and found that ghostscript can do this: gs ...


16

TeX only processes the input line by line, so there is a limit on the number of characters in a line, but not on the total size of the file. Your editor however probably does need to read the entire file into memory so may have limits on the file size. The editor I use warns if the file is more than 10MB but will open files larger than that, up to the ...


15

There is the program pdfopt provided by Ghostscript which converts the PDF in the official web optimised format. This (quote from man pdfopt) puts the elements of the file into a more linear order and adds "hint" pointers, allowing Adobe's Acrobat(TM) products to display individual pages of the file more quickly when accessing the file through a ...


14

(Not specifically font related) A way to create smaller documents with pdf(La)TeX is to use \pdfminorversion=5 \pdfobjcompresslevel=3 \pdfcompresslevel=9 This will generally produce considerably smaller files but it requires pdf version 1.5 and might not be readable by old pdf-viewers.


13

For you minimal example it is the font format which makes the difference. This can be seen by comparing the PDFs in an editor which supports binary (like vim). Also pdffonts is helpful: xelatex: (1874 bytes compressed, 2444 bytes uncompressed) name type emb sub uni object ID ------------------------------------ ...


13

Using true type fonts that are specified in the PDF standard (and thus available with every conforming pdf viewer) dramatically reduces for me the file size of PDFs generated with pdflatex. Else, other fonts are included in the generated PDF which increases the file size. For example via \usepackage{mathptmx} \usepackage[scaled=.95]{helvet} ...


11

The PGF package allows you to use a grayscale JPEG as a soft mask for your image. Suppose you have a PNG with transparency called image.png. Then you can convert the picture to a colour JPEG using the ImageMagick command convert image.png image.jpg and extract the transparency mask to a grayscale JPEG using convert image.png -alpha extract -colorspace ...


11

MacTeX is, as the other answer says, basically TeX Live with a few extras. The extras are things like TeX Shop, a Mac-only TeX editor. The reason TeX Live is so big is that there are a lot of LaTeX packages, and most have documentation in PDF format. It's actually this documentation that takes up a lot of the space. You can install only part of TeX Live, but ...


10

This is really just a comment on Sharpie's answer, but I don't have the reputation to comment yet. If tlmgr install <pkg> doesn't work, try tlmgr search <pkg> as a way of automating the CTAN search (or tlmgr search --global --all <pkg>, if you really want to go wild). Here's a recent example that cropped up for me when trying to compile ...


8

There is no package makemypdfsmaller.sty which reduces the PDF file size without removing information. However, there are a few things you can do: Reduce number of images Do you really need to include eighteen images? Maybe sixteen or twelve is enough. Reduce image size You can use imagemagick (or gimp or …) to reduce the image size. You have to ...


7

I do not know how to make lualatex output Type 1C fonts. However, you may be able to use ps2pdf to convert a PDF containing Type 1 fonts to another PDF containing Type1C fonts. You should carefully choose parameters to ps2pdf. For example: newell:~/latex/help $ du -h plain.pdf 60K plain.pdf newell:~/latex/help $ pdffonts plain.pdf name ...


7

No, saveboxes created with \sbox and friends do not reduce the final file size. The content is written to the output file every time it is used in the document. I actually wrote a LaTeX package storebox which provides "storeboxes" which work like saveboxes but only store the content once in the PDF. However, this only works with pdflatex in PDF mode, not ...


7

Luatex never writes Type1C fonts. You will get smaller pdfs if you use OpenType/TrueType fonts instead of Type1 (luatex writes CIDType0 fonts for those) but otherwise pstopdf is the alternative. Unless someone supplies a patch, this situation is unlikely to change.


7

The TeXlive version has compressed object streams. That indicates that MikTeX and TeXlive have different settings for \pdfobjcompresslevel. compressed object streams is a lossless compression method, where not just a single object is compressed, but a range of objects. This leads to smaller sizes. Why one distribution would set it as a default and the other ...


7

Clipping graphics or boxes is implemented at the driver level. That means that the entire original item is included in the output, and that the driver is then told only to make part of it visible. As such, clipping/viewports can never reduce file size. For a vector graphic, the same would be true even if you made a standalone image and then included that in ...


7

A TeX compiler is not an image processing program. The image is just included in total. Trimming/clipping is applied via PDF (PostScript) operators without changing the image. Load the image into an image processing program (gimp or many other), remove the unwanted parts there. Depending on the image, it could also be downscaled or exported in a different ...


6

I really like the script by Alexander Grahn but I am missing a feature to still allow a small margin. I made a small modification to the script to allow this margin like the original PDF crop does. Since I'm new to this part of Stack Exchange I can't comment so I'll post the entire script here. Unfortunately I suck at bash so I wasted some time trying to ...


6

As Manuel suggested in his comment, split your document into several files and your experienced sluggishness will most likely go away. Just have one "thesis.tex" file from which you call all your chapters. \documentclass{article} \begin{document} \input{chapterOne.tex} \input{chapterTwo.tex} \end{document} If you don't find that solution satisfactory, I ...


6

Give this a try: #!/bin/bash file=$1 filebase=$(basename $file .pdf) gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=${filebase}_verkleinert.pdf ${filebase}.pdf Save it as a shell script and call it with sh <shellscriptname>.sh <nameofyourpdffile>


6

I use a python script found here: http://www.mobileread.com/forums/showthread.php?t=25565 with following features: output has reasonable size as you requested supports absolute cropping (in case automatically computed bounding box is not useful when you have horizontal footer or header bars) it is awesome fast: for 200 pages in less than a second! Of ...


4

It is important to note that (La)TeX interprets the code and generates output. Output in this instance is the resulting PDF which, in its binary form, consists of a bunch of shapes (circles, lines, rectangles and some embedded content like fonts, perhaps). It may be that the interpretation of (2,3) results in a generalized representation of ...


4

As described in my answer to the other question about shrinking pdf files you can use pdfsizeopt to do lossless compression of your pdf. If it turns out to be necessary to do lossy compression, then adobe acrobat professional has a "PDF optimzer" tool that can do this.


4

There are macros to control the compression level of pdf. I do not have the reference at hand, but I believe the macro (for pdflatex) is \pdfcompresslevel=<integer>. Even further compression can be archived if \pdfminorversion=5 (or something like this) because a particular pdf version introduced not just stream data compression but also compression of ...



Only top voted, non community-wiki answers of a minimum length are eligible