Anyway to reduce size of pdf using python script.

dieter dieter at handshake.de
Sat Sep 6 08:09:09 CEST 2014


kekeje at gmail.com writes:

> On Friday, February 1, 2013 8:03:41 PM UTC-5, access... at gmail.com wrote:
>> I have a batch file that exports ArcGIS pdf maps to a directory. I would like to include a step in the script where the pdf file is reduced in size instead of manually opening each file in Acrobat X Pro after the script has run and doing it there.
>> 
>> Can this be done using python scripting or does the automation stop at exporting the map?
>
> Have you found the solution? I am having exactly the same problem and happen to see your post here. Please let me know how you did it, thanks! 

Python is a (mostly) general purpose programming language.
To optimize "PDF" specialized PDF knowledge is requires - which
Python, by itself, lacks.

You may check whether "Acrobat X Pro" is scriptable (can be controlled
externally). Windows programs sometimes expose a COM interface
for such external control (also called "automation"). If "Acrobat"
supports automation via COM interfaces, the you can use Python
to "drive the automation" (some Python versions for Windows come
with COM support).

The required PDF knowledge may also come from special (Python extension)
packages. "reportlab" provides Python extensions to handle PDF.
I do not know whether this includes optimizing "PDF" (I use
a "reportlab" package to generate PDF from Python scripts).

I expect that the optimization you observe results from compressing
the images included in the PDF. If this is the case,
you could in principle write your own package to do this in Python.
You would need to learn PDF internals for this.




More information about the Python-list mailing list