sriram_perl_diver has asked for the wisdom of the Perl Monks concerning the following question:
Please help me out! Thanks in advance#!/usr/bin/perl -w use warnings; use Data::Dumper; ##################### #Including libraries# ##################### use lib '/**/PDFlib'; use lib '/**/PDFModules'; use PDFlib; use POSIX qw(strftime); use File::Copy; use constant MARGIN => 30; use constant PAGE_WIDTH => 792; use constant PAGE_HEIGHT => 612; use constant TOOLTIP_TEXT => ''; use constant SAMPLE_TEXT => 'Test'; my $dir = "."; open INDEX, "$dir/input/index.txt" or die "\nError opening index file. + Please check if the index file exists.\n\n"; my @Inarr; while(<INDEX>) { my $line = $_; chomp($line); print "$line\n"; push @Inarr, "$line"; } close INDEX; my $src_dir = './input'; my $inputFile = substr $Inarr[2], 0, 39; my $dest_dir = './output'; if (length $inputFile == 0) { die("\nIndex file does not have the Input PDF file name.\n\n"); } my $log_dir = "$dest_dir/logs"; my $pdf_dir_name = substr $inputFile,0,-4; my $pdf_dir = "$dest_dir/$pdf_dir_name"; my $i = 0; my $pdfInstance = new PDFlib::PDFlib; $pdfInstance->set_option("resourcefile","/PDFlib/PDF/pdflib.upr"); my $date = strftime "%m%d%Y", localtime; my $time = strftime "%m%d%Y_%H%M%S", localtime; my $newLogFile = "report-$time.txt"; ##################################### #Creating Log and Output directories# ##################################### mkdir $dest_dir unless -d $dest_dir; chmod 0755, $dest_dir; mkdir $log_dir unless -d $log_dir; chmod 0755, $log_dir; mkdir $pdf_dir unless -d $pdf_dir; chmod 0755, $pdf_dir; my $infile_path = "$src_dir/$inputFile"; open LOGFILE, ">$log_dir/$newLogFile" or die "\nError creating Log fil +e.\n\n"; print LOGFILE "-Begin Log. Timestamp:$time-"; print LOGFILE "\n"; my $outfile = $pdf_dir.'/'."modified_".$pdf_dir_name.'.pdf'; if ($pdfInstance->begin_document("$outfile", "compatibility=1.7ext3") +== -1) { print LOGFILE ("ERROR in creating Output document:", $pdfInstance- +>get_errmsg()); print LOGFILE "\n-End of Log-"; print "\nError in creating Output document.\n\n"; } my $font = $pdfInstance->load_font("Helvetica", "winansi", ""); if ($font == 0) { print LOGFILE ("\nERROR in creating font instance:", $pdfInstance- +>get_errmsg()); print "\nERROR in creating font instance\n\n"; } my $opendoc = $pdfInstance->open_pdi_document($infile_path, ""); if ($opendoc == -1) { print LOGFILE ("ERROR in opening Input PDF file:", $pdfInstance->g +et_errmsg()); print LOGFILE "\n-End of Log-"; print "\nError in opening Input PDF file.\n\n"; exit; } $pdfInstance->set_info("Creator","Sriram"); $pdfInstance->set_info("Title", "Test"); my $pagehdl = $pdfInstance->open_pdi_page($opendoc, 1, ""); if ($pagehdl == -1) { print LOGFILE ("ERROR in opening the Input PDF file instance:", $p +dfInstance->get_errmsg()); print LOGFILE "\n-End of Log-"; print "\nError in opening the Input PDF file instance.\n\n"; } $pdfInstance->begin_page_ext(10, 10, ""); $pdfInstance->fit_pdi_page($pagehdl, 0, 0, "adjustpage"); $pdfInstance->close_pdi_page($pagehdl); $newoptlist = "barcode={symbology=DataMatrix dataprep=0 ecc=0 xsymwidt +h=10} font=" . $font; if($pdfInstance->create_field(180, 360, 288, 276, "testvalue", "textfi +eld", $newoptlist)) { print LOGFILE "\nField created\n"; } $pdfInstance->end_page_ext(""); $pdfInstance->close_pdi_document($opendoc); print LOGFILE "-End of Log-"; print "\nProcess completed successfully.\n\n"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with PDFLIB barcode generation
by toolic (Bishop) on Nov 05, 2014 at 17:48 UTC | |
by sriram_perl_diver (Novice) on Nov 06, 2014 at 05:11 UTC | |
by toolic (Bishop) on Nov 06, 2014 at 15:14 UTC | |
|
Re: Problem with PDFLIB barcode generation
by perlron (Pilgrim) on Nov 05, 2014 at 17:58 UTC | |
by sriram_perl_diver (Novice) on Nov 06, 2014 at 05:21 UTC | |
by perlron (Pilgrim) on Nov 06, 2014 at 10:21 UTC |