Skip to content

Instantly share code, notes, and snippets.

@JJ
Created November 26, 2022 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JJ/44e68da7b4f82a070a438b5dae59b754 to your computer and use it in GitHub Desktop.
Save JJ/44e68da7b4f82a070a438b5dae59b754 to your computer and use it in GitHub Desktop.
Combine PDs by Tom Browder
use PDF::Lite;
use PDF::Font::Loader;
my @pdfs = <list of pdf files to combine>;
# create a new pdf to hold the entire collection
my $pdf = PDF::Lite.new;
$pdf.media-box = 'Letter';
my $centerx = 4.25*72; # horizontal center of the page
# the cover
my PDF::Lite::Page $page = $pdf.add-page;
# add the cover title info...
for @pdfs -> $pdfdoc {
# the cover
$page = $pdf.add-page;
# add the part cover title info...
my pdf2 = PDF::Lite.open: $pdfdoc;
my $npages = $pdf2.page-count;
1..$npages -> $page-num {
$pdf.add-page: $pdf2.page($page-num);
}
}
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment