Perl-Sensitive Sunglasses | |
PerlMonks |
Generating multi page PDF with bitmap images, vector graphics and text.by chrestomanci (Priest) |
on Nov 21, 2010 at 22:29 UTC ( [id://872827]=perlquestion: print w/replies, xml ) | Need Help?? |
chrestomanci has asked for the wisdom of the Perl Monks concerning the following question: Greetings fellow monks. I am attempting to write a perl script that will generate a pdf file of about 100 pages. Each page needs to contain over 100 bitmap images, and also some text labels and vector graphics. The images are to be laid out in a regular grid pattern, and the overall format layout of each page in the document will be the same. (Different images and labels will be used on each page.) I have tried a number of different approaches, and none provide a complete solution, so I would like the advice of the monastery on how I might solve the problem. My basic algorithm looks like this: (pseudocode)
I first tried PDF::Report (which you can see in my code example, however, I found that the vector graphics support does not work properly. When I attempted to draw shapes. (Simple polygons), they did not appear in the output. There also appears to be no support for rotated text. I then took a look at the perl bindings for Cairo, and while the support for rotated text and vector graphics are excellent, I can't figure out if there is support for bitmap images, (if there is, it is not documented well). Also there does not appear to be support for multi page PDF output. I then thought I could go via SVG as an intermediate format, and convert it to PDF using inkscape's svg2pdf tool. The source PDF could be generated either using GD::SVG, or by preparing an SVG template by hand, and then using Template Toolkit to fill it in with the different images and labels for each page. (The vector graphics are the same on each page). I have not so far written any code to try this approach. I am aware of pdftk, so I know that I can join may single page PDF files into one multi page one fairly easily, However it would be nice to be able to use a library that supports multi page PDF natively. Given my lengthy description of the problem, can anyone offer suggestions on the best way to proceed from here?
Back to
Seekers of Perl Wisdom
|
|