#!usr/bin/perl use Term::ReadKey; do 'user_options.pl'; do 'createpdf.pl'; print "Program ON\n"; ReadMode 4; # Turn off controls keys $input=0; until ($input eq "q"){ while (not defined ($input = ReadKey(-1))) { do 'appendpdf.pl'; sleep(1); } } ReadMode 0; # Reset tty mode before exiting print "\nProgram OFF\n"; #### use CAM::PDF; use File::Copy; #Initialize title page pdf my $doc1 = CAM::PDF->new("$file1") || die "$CAM::PDF::errstr\n"; #Read each pdf file on the desktop opendir(DIR,$directory); my @files = grep{/\.pdf$/}readdir(DIR); closedir(DIR); #Get the names of all the files. foreach(@files[0]){ $name2=$_; $file2="$directory"."$name2"; $doc2 = CAM::PDF->new("$file2") || die "$CAM::PDF::errstr\n"; #Append the thermogram file with each document $doc1->appendPDF($doc2); $doc1->clearAnnotations(); $doc1->cleanoutput("$file1"); #Move each file to the destination folder $file3="$destination"."$name2"; move("$file2","$file3") || die "Move failed: $!"; $file2->close || die "Source file failed to close: $!"; $file3->close|| die "Target file failed to close: $!"; } #### $file1="$output"."$filename"; use PDF::Create; # initialize PDF my $pdf = PDF::Create->new('filename'=> "$file1",'CreationDate' => [ localtime ], ) || die "Could not initialize PDF."; # add a A4 sized page my $a4 = $pdf->new_page('MediaBox' => $pdf->get_page_size('A4')); # Add a page which inherits its attributes from $a4 my $page1 = $a4->new_page; # Prepare a font my $f1 = $pdf->font('BaseFont' => 'Helvetica'); #prompt for user input print "\n"; print "Name: "; $name=<>; print "Method: "; $method=<>; print "\n"; #get the date $date=localtime; # Write some text $page1->stringc($f1, 20, 306, 425, "$title"); $page1->stringc($f1, 20, 306, 375, "Author: $name"); $page1->stringc($f1, 20, 306, 350, "Method: $method"); $page1->stringc($f1, 20, 306, 300, "$date\n"); # Close the file and write the PDF $pdf->close || die "Could not write PDF."; #### #The directory where the files that need to be appended are located: $directory = 'C:/Users/X/Desktop/'; #This is where the final pdf file will print: $output = 'M:/perlscripts/'; #This is where the spent files will be collected: $destination='C:/Users/X/Desktop/Generated Thermograms/'; #This is what your final file name will be: $filename='Thermograms.pdf'; #The title in the PDF: $title='Thermograms';