use PDF::API2; use constant mm => 25.4 / 72; use constant in => 1 / 72; use constant pt => 1; # Create a blank PDF file my $pdf = PDF::API2->new(); # Add a blank page my $page = $pdf->page(); # Set the page size $page->mediabox('Letter'); $pdf->info( 'Author'=>'COPA', 'Title'=>'perl PDF API2 Test', ); $imageFile = "/home/images/test.png"; $img = $pdf->image_png($imageFile); $image = $page->gfx; $image->image($img, 0/mm, 100/mm); # print output $http_headers_out{'Content-Disposition'} = "inline; filename=pdfTest.pdf"; $http_headers_out{'Content-type'} = "application/pdf"; $escmode = 0; print OUT $pdf->stringify; $pdf->end;