Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Anyway to reduce size of pdf using python script.

2,856 views
Skip to first unread message

access...@gmail.com

unread,
Feb 1, 2013, 8:03:41 PM2/1/13
to
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?

Thanks

Roy Smith

unread,
Feb 1, 2013, 8:10:09 PM2/1/13
to
In article <a672024e-2df2-4c88...@googlegroups.com>,
I don't know anything about ArcGIS, but
http://stackoverflow.com/questions/6413441/python-pdf-library gives
pointers to several libraries which look like they might do what you
want.

kek...@gmail.com

unread,
Sep 5, 2014, 2:56:29 PM9/5/14
to
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!

Tim

unread,
Sep 5, 2014, 3:36:49 PM9/5/14
to
On Friday, February 1, 2013 8:03:41 PM UTC-5, access...@gmail.com wrote:
I don't have a definitive answer but I use qpdf to optimize my pdf files. Whether that reduces the size I'm not sure. http://qpdf.sourceforge.net/

--Tim

dieter

unread,
Sep 6, 2014, 2:09:37 AM9/6/14
to pytho...@python.org
kek...@gmail.com writes:

> On Friday, February 1, 2013 8:03:41 PM UTC-5, access...@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.

0 new messages