SPUG:How to bundle images in PDF?

SPUG-list-owner tim at consultix-inc.com
Tue Jul 1 23:18:13 CDT 2003


On Tue, Jul 01, 2003 at 10:04:09PM -0500, Jeff Almeida wrote:
> 
> >#! /usr/bin/perl -w
> >
> >use PDF::API2;
> >my $pdf = PDF::API2->new(-fit=>1);
> >
> >( $img_x, $img_y ) = ( 717, 538 );
> >( $x, $y ) = ( $img_x + 72, $img_y + 18);
> >
> >$pdf->mediabox($x,$y) ;
> 
> That's kinda a nonstandard size for a global mediabox, and might cause 
> problems with some viewers..?

Works fine with acroread and gv on Linux, and IMHO the whole idea
of custom sizes is to enjoy being non-standard!  But I think the
real problem is below, as you pointed out.
 
> >my ($img,$llx,$lly,$urx,$ury) = qw( 36 36  ) ;

Of course, now that I look at that line, it looks *atrocious*;
I can only speculate that I got interrupted by a phone call
or email in the middle of typing it, and then grew accustomed
to its appearance and never doubted it later on, especially
because everything was working fine (on Linux anyway).
Know what I mean? 8-}

> This line makes me cringe, especially when combined with the results 
> below...

I cringe with you . . .
 
> >foreach (@ARGV) {
> >	my ($img) = $pdf->image_jpeg($_);
> >	my ($page) = $pdf->page();
> >	my ($gfx) = $page->gfx();
> 
> Good so far, instantiating an image, a page, and a graphics context for 
> putting the image on the page...
> 
> >	$gfx->image($img,$llx,$lly,$urx,$ury);
> 
> Right now, though, the above call is trying to set the geometry for the 
> image on the page with three of the four coordinates undefined.  What you 
> probably wanted was a combination of
> 
> my ($llx,$lly) = qw (36 36); #above, replacing the controversial line early
> 
> and $gfx->image($img,$llx,$lly); #in place of your existing call

Again, I plead "codus interruptus",  or perhaps temporary insanity.
In any case, thanks for pointing out what I didn't see!  I'll check
out your suggestions.
 
> Which will put the image a half-inch up and in from the lower right hand 
> corner of the global mediabox (which the way you've set it, will actually 
> cause the image to spill an eighth of an inch off the top) and not attempt 
> to force the image size to conform.
> 
> ************************************************************
> Jeff D. "Spud (Zeppelin)" Almeida
> Little Elm, TX
> spud at spudzeppelin.com

-- 

-Tim
*------------------------------------------------------------*
| Tim Maher (206) 781-UNIX  (866) DOC-PERL  (866) DOC-UNIX   |
| CEO, JAWCAR ("Just Another White Camel Award Recipient")   |
| tim(AT)Consultix-Inc.Com  TeachMeUnix.Com  TeachMePerl.Com |
*+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-*
|  Watch for my Book: "Minimal Perl for Shell Programmers"   |
*------------------------------------------------------------*



More information about the spug-list mailing list