Skip to content

Instantly share code, notes, and snippets.

@melo
Created January 9, 2013 17:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melo/4494996 to your computer and use it in GitHub Desktop.
Save melo/4494996 to your computer and use it in GitHub Desktop.
Merge the content of two single page PDFs, on a pretty template, the other an invoice, into a new *single* page PDF, using Perl PDF::API2
#!/usr/bin/env perl
use strict;
use warnings;
use PDF::API2;
my ($template_pdf, $data_pdf) = @ARGV;
my $t_pdf = PDF::API2->open($template_pdf);
my $page = $t_pdf->openpage(1);
my $d_pdf = PDF::API2->open($data_pdf);
$t_pdf->importpage($d_pdf, 1, $page);
$t_pdf->saveas("merged-$data_pdf");
$t_pdf->end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment