MidLifeXis has asked for the wisdom of the Perl Monks concerning the following question:

PDF:API2 used to have a method pdfimage that would allow you to grab a page of a PDF file and treat the return value like an image. This appears to no longer be viable.

What would be the new way to pull a page from one document, scale it, and place it into an existing page in another document? I have seen CAD::PDF, but I don't have it installed (yet), and would prefer not to have to load yet another PDF library. CAD::PDF does look useful, however, so I will be looking at it in the future.

--MidLifeXis

Replies are listed 'Best First'.
Re: PDF::API2::pdfimage() - where did it go?
by snoopy (Curate) on May 08, 2007 at 23:10 UTC
    PDF::API2 now achieves the same result using two methods: importPageIntoForm and formimage. These share an intermediate form object.
    #!/usr/bin/perl use warnings; use strict; use PDF::API2; my $pdf = PDF::API2->new(); my $page = $pdf->page(0); # create new page $page->mediabox(100, 100); my $gfx = $page->gfx; my $import_pdf = PDF::API2->open('overlay.pdf'); my $xoform = $pdf->importPageIntoForm($import_pdf, my $_pagenum = 1); $gfx->formimage($xoform, my $_x = 10, my $_y = 20, my $_scale = .5); $pdf->saveas('test.pdf');