I want to merge multiple pdf files into one pdf using perl script.

I am new in perl script and using CAM::PDF module for merging PDFs but facing below error: Can't call method "appendPDF" on an undefined value.

Can you please help me where I am missing to assign values or doing wrong?

Code:

use CAM::PDF;

my $pdf1=CAM::PDF->new("pdf1.pdf");
my $pdf2=CAM::PDF->new("pdf2.pdf");

$pdf1->appendPDF($pdf2);
1

There are 1 best solutions below

0
On

Please specify the path so it will not give the error as in your case $pdf1 is undef (refer the below code):

use CAM::PDF;

my $pdf1=CAM::PDF->new("/home/xyz/pdf1.pdf");
my $pdf2=CAM::PDF->new("/home/xyz/pdf2.pdf");

$pdf1->appendPDF($pdf2);