Sunday, 15 July 2012

PoDoFoColor Lua Scripting


sdaau wrote in with some news about podofocolor, I'd like to share:

I just found about podofocolor on http://domseichter.blogspot.dk/2011/01/modifying-and-analyzing-colors-in-pdf.html - and I got really interested in "Analyzing colors - Find out, which colorspaces or colors are used in a PDF". I couldn't find an example of how to do that on that page, and I assumed the only way to do is through Lua.

Unfortunately, while there are some PPA builds for Ubuntu ( see http://sdaaubckp.svn.sf.net/viewvc/sdaaubckp/offext-call-scripts/podofo.sh ), those do not have Lua built-in, so I rebuilt podofo and utils on Lucid, and posted the executables here - since they are statically linked, they may be useful to others as well:

http://sdaaubckp.sourceforge.net/post/libpodofo-utils-lucid/

I have also recorded the steps to building those executables in http://sdaaubckp.svn.sf.net/viewvc/sdaaubckp/source-build-scripts/get-podofo-src.sh

The above directory also contains a modification of the example.lua script:

http://sdaaubckp.sourceforge.net/post/libpodofo-utils-lucid/example-colorlist.lua

... which can be used to simply print out any color encountered in a PDF, by using this command line:

$ ./libpodofo-utils-lucid/podofocolor lua example-colorlist.lua /path/to/mytest.pdf /dev/null

<]/Info 2 0 R/Root 1 0 R/Size 16>>
Processing page 1...
-> Lua is parsing page: 1
Reading object 6 0 R with type: Number
set_non_stroking_color_gray: 1
set_non_stroking_color_cmyk: 0.233887 1 1 0.218994
....

Note that it is important to add `/dev/null` as output file - otherwise, both the color report _and the pdf in its entirety_ will be dumped to the terminal - making the report about colors impossible to read.

I would have appreciated a lot a similar guide/explanation on the blogspot webpage (or in a help/readme); and I'd be very happy if some of this here can contribute towards more detailed examples in then documentation.

Many thanks for the great software,
Cheers!  


The original post can be found here: http://sourceforge.net/tracker/?func=detail&aid=3539970&group_id=154028&atid=790133
If you also have interesting PoDoFo stuff to share, feel free to drop me a mail.

1 comment:

lingjie shi said...

I accidentally viewed your blog and I was so amazed with your work that it touched the deepness of my heart and it made me sentimental. Thanks for posting. Visit my site to buy fake watches uk small sizes