PDF::CreateSimple
This module let you create simple PDF files using a set of eary to use function. You can either create a file from scratch or start using an already existing file.
use PDF::CreateSimple; my $pdfFile = PDF::CreateSimple->new($pdfPath); #----------------------------------------------------------------------------- # Add a new page #----------------------------------------------------------------------------- $pdfFile->addNewPage; #----------------------------------------------------------------------------- # Write Text #----------------------------------------------------------------------------- $pdfFile->drawText('See what it can do!','Verdana',12,400,200,'cyan'); #----------------------------------------------------------------------------- # Create Straight and Curved Lines #----------------------------------------------------------------------------- $pdfFile->drawLine(0,0,50,50,1,'black'); $pdfFile->drawCurve(0,0,50,50,100,50,1,'olive'); #----------------------------------------------------------------------------- # Create Hollow Geometric Figures #----------------------------------------------------------------------------- $pdfFile->drawRectangle(0,0,50,50,2,'blue'); $pdfFile->drawPolygon([10,15,20,25,25,30,50,100,50,200],2,'orange'); #----------------------------------------------------------------------------- # Create Filled Geometric Figures #----------------------------------------------------------------------------- $pdfFile->drawCircle(100,100,30,3,'black','green'); $pdfFile->drawSquare(150,100,30,1,'olive','red'); #----------------------------------------------------------------------------- # Import Images (png,pnm,tiff,gif,jpg) and other PDF Files #----------------------------------------------------------------------------- $pdfFile->drawImage('some_img.jpg',150,150,1.75); $pdfFile->drawImage('some_other_img.jpg',350,150,200,200); $pdfFile->importPage('source_pdf'); #----------------------------------------------------------------------------- # Save And close #----------------------------------------------------------------------------- $pdfFile->closeFile;
lineWidth(integer) : Specefy the thickness of the lines defining the figures strokecolor : See color for more info fillcolor : Optional, when defined, the object will be filled using that color. If undef, the form will be hollow pageno : optional, when not defined, it will used the currently selected page.
Draw the text 'string' at (x,y) using the font 'font' of size fontSize and color 'color'. If align is undef or 0, the text will be left aligned at (x,y) If align is set to 1, the text will be centered at (x,y) If align is set to 2, the text will be right aligned at (x,y)
Draw a line at the specified coordinates from (x1,y1) to (x2,y2)
Draw a curve at the specified coordinates from (x1,y1) to (x2,y2) with a curve streching to reach the flex point(fx,fy)
Draw a rectangle using (x1,y1) and (x2,y2) as corner point
Draw a square using (x,y) as one of the corner and size as width and height
Draw a circle of center point(x,y) and radius r
Draw an ellipse of center point(x,y), horizontal radius r1 and vertical radius r2
Draw an arc of center point(x,y), horizontal radius r1 , versitcal radius r2 and going from degree alpha to beta
Draw a pie of center point (x,y), horizontal radius r1, vertical redius r2 and going from degree alpha to beta. Unlike an Arc, drawPie will close the form to make a pie slice shape form.
Draw a polygon using the specified points. Points format is (x1,y1,x2,y2,x3,y3,...,xn,yn)
draw a grid using two list of points for vertical line(xs) and horizontal lines(ys)
draw a grid starting at (x1,y1) and ending at (x2,y2) that have a vertical line at every 'xInt' and an horizontal line at every 'yInt'
Draw a pie chart at center point (x,y), horizontal radius r1 and vertical radius r2. Each item in values is a slice of the pie. The format of the values list is a hash string : the caption to display, value : the value of the item (used to calculate the size of the slice) color : the color of the pie slice If showString is set to true, the caption will be shown near the slice. If showValue is set to true, the value will be shown near the slice. If both showString and showValue are set to true, the label that will appear near the slice will be string(value)
Import an image found in path and draw it with left,bottom corner point at (x,y). If scale is defined, but not h, the image size will be multiplied by 'scale' (ex: 0.5 would print it at half its size) If both scale and h is defined, then the image will be resized to width of 'scale' and height of 'h' Currently supported image format are png,pnm,jpeg,gif and tiff
Import a page from another pdf file into this one. The source page will be 'sourcePageIndex' and will be inserted before the 'pageNo'th page (ex: if pageNo = 2, it will insert between the first and second page) If pageNo is set to 0 or undef, the page will be inserted at the end. The current page will also be set to the newly created page.
Set the rotation angle to 'angle' degree (not radian). All future objects (except an inported pdf page) will be rotated counter-clockwise by that angle until it is changed. To remove the rotation, either set it to 0 or call resetTransformations. setRotation is not additive (ex : setRotation(15); setRotation(25) will set it to 25, not 40)
Set the skewness to (x,y). All future objects (except an inported pdf page), will be skewed until it is changed. To remove skewness, either set it to (0,0) or call resetTransformations setSkew is not additive (ex : setSkew(1,1); setSkew(2,3) will set it to (2,3), not (3,4))
Reset both rotation and skewness to none.
Add a new page before the 'pageNo'th page (ex: addNewPage(1) will add at the beginnig, while addNewPage(3) will add between the second and third page) If pageNo is set to 0 or undef, it will add at the end.
Change the current page to 'pageNo'. If set to 0 or undef, will go at the last page.
Create the PDF::CreateSimple object. The file will be put at outPath. If inpath is defined, the new pdf will be a copy of inPath at start. If not defined, it will be a one page blank pdf file.
Return the PDF::API2 object used by the package. Do not use this unless you really know what you are doing.
Change the file location of the pdf file to path.
Return the location of the pdf file
Return the content of the file. If isBinary is set to true, the content will be in binary format. Otherwise is ASCII format.
The following fonts are supported by PDF::CreateSimple
"Adobe Font" Courier Courier-Bold Courier-BoldOblique Courier-Oblique Helvetica Helvetica-Bold Helvetica-BoldOblique Helvetica-Oblique Symbol Times-Bold Times-BoldItalic Times-Italic Times-Roman ZapfDingbats "Windows Fonts" Georgia Georgia,Bold Georgia,BoldItalic Georgia,Italic Verdana Verdana,Bold Verdana,BoldItalic Verdana,Italic Webdings Wingdings
The following colors are available in text format :
aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen, darkgrey, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgreen, lightgrey, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen
You can also define a color using the "#RRGGBB" notation
This module is still in development phase, so comments and suggestions about new stuff to added or corrections are welcomed.
None known yet
First of all, I would like to thank alfred reibenschuh, the author of PDF::API2. In no particular order: Philippe Coté, author of Devel::Monitor and Julien Gervais-Bird, my boss.
David Brunelle < david.brunelle@usherbrooke.ca > Génome Québec < http://www.genomequebec.com >
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'Coté,'. Assuming CP1252
To install PDF::CreateSimple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PDF::CreateSimple
CPAN shell
perl -MCPAN -e shell install PDF::CreateSimple
For more information on module installation, please visit the detailed CPAN module installation guide.