Last active
March 14, 2023 05:26
-
-
Save rwp0/410d4a3792dcbfbcd2998a719b8c73c4 to your computer and use it in GitHub Desktop.
Merge PDF Documents using PDF-API2 Perl Distribution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env perl | |
use v5.37.9; | |
use PDF::API2; | |
chdir 'PATH_WITH_PDFS'; | |
my $pdf = PDF::API2 -> new; | |
my $source1 = PDF::API2 -> open( '1.pdf' ); | |
my $source2 = PDF::API2 -> open( '2.pdf' ); | |
my $page1 = $pdf -> import_page( $source1 ); | |
my $page2 = $pdf -> import_page( $source2 ); | |
$pdf -> save( 'all.pdf' ); | |
# Method: https://metacpan.org/pod/PDF::API2#import_page | |
# cf. mutool merge -o all.pdf 1.pdf 2.pdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment