<?xml version="1.0" encoding="windows-1252"?>
<node id="772236" title="One PDF file for a set of images" created="2009-06-17 01:57:49" updated="2009-06-17 01:57:49">
<type id="1980">
snippet</type>
<author id="44715">
graff</author>
<data>
<field name="doctext">
</field>
<field name="snippetdesc">
I had to scan a bunch of paper documents (one image per page), and upload them all to a web site that would accept only one PDF file containing the whole set.&lt;P&gt;A few CPAN module can do this, but their man pages leave a lot to the imagination.  After a dozen trial/error iterations, here's what worked for me, using [mod://PDF::Create] (it's manual was much better than [mod://PDF::API2]).</field>
<field name="snippetcode">
&lt;CODE&gt;
#!/usr/bin/perl

use strict;
use warnings;
use PDF::Create;

my $pdf = new PDF::Create(filename=&gt;"test.pdf",Author=&gt;"Me");
my $psz = $pdf-&gt;get_page_size("Letter");
my $rt = $pdf-&gt;new_page( MediaBox =&gt; $psz );
for my $i (&lt;*.jpg&gt;) {
    my $im = $pdf-&gt;image($i);
    my $pg = $rt-&gt;new_page( MediaBox =&gt; $psz );
    $pg-&gt;image( image =&gt; $im,
		xpos =&gt; 0, ypos =&gt; 0,
		xscale =&gt; $$psz[2] / $$im{width},
		yscale =&gt; $$psz[3] / $$im{height}
	);
}
$pdf-&gt;close;

&lt;/CODE&gt;</field>
</data>
</node>
