Theses, Books, Title pagesHow to reduce file size of PDF output while compile with pdflatex

Classicthesis, Bachelor and Master thesis, PhD, Doctoral degree
byn
Posts: 56
Joined: Fri Jun 10, 2022 12:27 pm

How to reduce file size of PDF output while compile with pdflatex

Post by byn »

I am using pdflatex to compile on a windows system and I wonder how the file size can be reduced while compiling with pdflatex

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

How to reduce file size of PDF output while compile with pdflatex

Post by Stefan Kottwitz »

Hi,

try Joseph's suggestion here: make PDF file size smaller.

Stefan
LaTeX.org admin
byn
Posts: 56
Joined: Fri Jun 10, 2022 12:27 pm

How to reduce file size of PDF output while compile with pdflatex

Post by byn »

Hi Stefan,

I run the code

\pdfminorversion=5
\pdfcompresslevel=9
\pdfobjcompresslevel=2

but i didn't notice any difference, is there a workaround script?

Byn.
byn
Posts: 56
Joined: Fri Jun 10, 2022 12:27 pm

How to reduce file size of PDF output while compile with pdflatex

Post by byn »

Does anyone know how to use ghostscript to compress a file on a windows system.

I found an answer here saying it is works but dont know how to invoke it?

https://tex.stackexchange.com/questions ... is-too-big which works for pdflatex but on a unix system.

Script is here

gswin64c -dCompatibilityLevel=1.5 -dAutoRotatePages=/None -dQUIET -sDEVICE=pdfwrite -o "out.pdf" "in.pdf"

code snippet.
code snippet.
Capture-1.PNG (41.08 KiB) Viewed 18111 times
Byn
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

How to reduce file size of PDF output while compile with pdflatex

Post by Stefan Kottwitz »

Hi Byn,

that should be done the command line aka command prompt: Windows Startmenu, Search, type cmd. Or search for the command line application.

And it has to be done within the document folder aka directory. If needed, use the cd command to change into that directory.

Stefan
LaTeX.org admin
byn
Posts: 56
Joined: Fri Jun 10, 2022 12:27 pm

How to reduce file size of PDF output while compile with pdflatex

Post by byn »

The code, doesn't seem to work for me, see error log below,
Capture-2.PNG
Capture-2.PNG (4.92 KiB) Viewed 18071 times
Have you had a try on it Stefan?
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

How to reduce file size of PDF output while compile with pdflatex

Post by rais »

byn wrote:Does anyone know how to use ghostscript to compress a file on a windows system.

I found an answer here saying it is works but dont know how to invoke it?

https://tex.stackexchange.com/questions ... is-too-big which works for pdflatex but on a unix system.
Whatever let you draw that conclusion? The very name "gswin64c" suggests a binary compiled for usage under M$ Windows. Under Unix and Unix-like platforms it's called "gs".
At the end of the Invoking Ghostscript section you'll find a brief overview for the different names on different platforms.
byn wrote: The code, doesn't seem to work for me, see error log below, [..]
bash? That sounds more like Unix than M$ Windows...try gs instead of gswin64c.

KR
Rainer
byn
Posts: 56
Joined: Fri Jun 10, 2022 12:27 pm

How to reduce file size of PDF output while compile with pdflatex

Post by byn »

Rais,

Thank you, I tried it but it returned an error below;
Capture-3.PNG
Capture-3.PNG (15.98 KiB) Viewed 18029 times
my template is here; https://drive.google.com/file/d/17UKBW9 ... cjNa6/view

Could you demonstrate it with my template it would be easier if I can run it while compiling, I am using TeX live though I have a cygwin installation on windows.
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

How to reduce file size of PDF output while compile with pdflatex

Post by rais »

Well, you just need to replace "in.pdf" with the file you created with pdflatex and I'd suggest a different name for the result instead of "out.pdf", too, e.g.,

Code: Select all

gs -dCompatibilityLevel=1.5 -dAutoRotatePages=/None -dQUIET -sDEVICE=pdfwrite -o main-template-reduced.pdf main-template.pdf
that created a pdf with 132K out of your 293K ;)

KR
Rainer
byn
Posts: 56
Joined: Fri Jun 10, 2022 12:27 pm

How to reduce file size of PDF output while compile with pdflatex

Post by byn »

Rais,

Still getting an error of unbalanced dictionary, below, how do you resolve this?
Capture-4.PNG
Capture-4.PNG (45.43 KiB) Viewed 18017 times
Post Reply