Perl Program for JPG to PDF conversition / JPG to PDF conversion
Submit your Email Address for future email alerts
Below is the Program for converting
JPEG file to PDF in Linux Machine.
First we have to install PDF::API2::Lite from CPAN.
#Use CPAN Module
use PDF::API2::Lite;
#create an object API2::Lite
$pdf = PDF::API2::Lite->new;
#Set the Page size
$pdf->page(595,842);
#Create the Object for the Target Image
$img = $pdf->image_jpeg(’/home/jeevan/Desktop/TestFile.jpg’);
$pdf->image($img,100,500,400,400);
#Set the Font family
$font = $pdf->corefont(’Times-Roman’);
#Printing the Text on the PDF $pdf->print($font,24,250,700,0,’right’,'This is My First PDF !’);
#Saving the PDF in the target folder
$pdf->saveas(’/home/jeevan/Desktop/MyFirstPDF.pdf’);
a2pdf : Command-line utility to convert ASCII text to PDF format.
The binary packages are available for Linux, Windows & Mac OS.
Note: The binary packages are completely self-contained with no external dependencies (not even Perl!).
Usage
a2pdf [options] input.txt >output.pdf
Dependencies
To install from source, a2pdf requires the PDF::API2 Perl module (tested with PDF::API2 version 0.60).
Additionally Perl::Tidy is required to perform Perl syntax highlighting.
To include images in the page header, the modules File::Type and Image::Size must also be installed.
Download the source code a2pdf