SPUG:How to bundle images in PDF?

Jeff Almeida spud at spudzeppelin.com
Mon Jun 30 08:59:38 CDT 2003


Tim was talking about this solution I sent him Saturday morning, but I don't 
think I actually sent it to the list, so here goes:

Also Sprach Tim Maher:
>Can anybody give me some pointers in how to accomplish this
>goal, or give me a better alternative?

use PDF::API2;
my $pdf = PDF::API2->new();
my @slides = (file1.jpg,file2.jpg,file3.jpg);
foreach (@slides) {
	my ($img) = $pdf->image_jpeg($_);
	my ($page) = $pdf->page();
	my ($gfx) = $page->gfx();
	$gfx->image($img,$llx,$lly,$urx,$ury);
}
my ($output) = $pdf->stringify();
print "$output";

and indirect accordingly :)

(n.b. llx, lly, urx, ury are the coordinates of the lower left corner and 
upper right corner you want the image on the page (where the lower left 
corner of the global context is 0,0, and there are 72 ppi).  You can set 
the page size with $pdf->mediabox($x,$y).  For example, landscape 8 1/2 x 
11, no automatic margins is $pdf->mediabox(792,612);  )

-- 

************************************************************
Jeff D. "Spud (Zeppelin)" Almeida
Little Elm, TX
spud at spudzeppelin.com



More information about the spug-list mailing list