Mark Howe > PDF-EasyPDF > PDF::EasyPDF

Download:
PDF-EasyPDF_0_04.tgz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  0
View/Report Bugs
Module Version: 0.04   Source  

NAME ^

PDF::EasyPDF - PDF creation from a one-file module, with postscript-like controls

SYNOPSIS ^

use PDF::EasyPDF;

my $pdf = PDF::EasyPDF->new({file=>"mypdffile.pdf",x=>mm(297),y=>mm(210)});

$pdf->setStrokeColor("CC0000");

$pdf->setStrokeWidth(8);

$pdf->rectangle(mm(10),mm(10),mm(297-20),mm(210-20));

$pdf->setFillColor("FFCC00");

$pdf->filledRectangle(mm(20),mm(20),mm(297-40),mm(210-40));

$pdf->setFillColor("CC0000");

$pdf->setFontFamily("Helvetica-Bold");

$pdf->setFontSize(24);

$pdf->text(mm(105),mm(210-22.5),"PDF::EasyPDF Demo");

$pdf->lines(mm(85),mm(35),mm(90),mm(105),mm(95),mm(35),mm(100),mm(105),mm(105),mm(35),mm(110),mm(105));

$pdf->setStrokeColor("000099");

$pdf->curve(300,300,300,400,400,400,400,300);

$pdf->setStrokeColor("0066FF");

$pdf->setFillColor("00FFFF");

$pdf->polygon(100,100,250,200,250,400,200,500);

$pdf->filledPolygon(100,100,250,200,250,400,200,500);

$pdf->close;

DESCRIPTION ^

This module started life as a workaround, on discovering that PDF::API2 and friends are extremely tricky to compile using Activestate's PerlApp utility because of the large number of runtime modules and resource files they use. The module consists of a single .pm file. It produces small PDF files, partly because it only uses the 14 standard PDF fonts. Page content is implemented using a single stream object, and the controls are vaguely postscript-like.

AUTHOR ^

Mark Howe, <melonman@cpan.org>

EXPORT

The mm and inch functions.

METHODS ^

new({file, x, y})

Creates a new PDF::EasyPDF object. The arguments are passed as an anonymous hash to allow, eventually, for different combinations of arguments. filename is the name of the PDF to be created (although nothing is output until the close method is called. x and y are the x and y dimensions of the page in points (see the mm and inch functions for a more convenient way to specify page sizes).

close()

Writes a pdf file.

fonts

Returns a list of supported fonts (currently the fourteen standard Adobe fonts).

setStrokeColor(rrggbb);

Sets the stroke (more or less 'line') colour using an html-like rrggbb string, ie FFFF00 = bright yellow.

setFillColor(rrggbb)

Sets the fill colour (including the text colour).

setStrokeWidth(width)

Sets the stroke (more or less 'line') width in points.

setFontFamily(fontname)

Sets the font.

setFontSize(size)

Sets the font size in points

setDash(lengths)

Sets the dash pattern. Pass a list of numbers to set the alternating 'on' and 'off' lengths in points, or, with no arguments, to reset to a solid line

setCap(style)

Set the cap style for the ends of lines. Options are round, square or butt.

setJoin(style)

Set the join style for lines. Options are round, bevel or miter.

text(x,y,string)

Places text at x,y

lines(x1,y1,x2,y2, ...)

Prints one or more lines, using alternative x and y coordinates.

polygon(x1,y1,x2,y2, ...)

Prints a closed, unfilled polygon using alternative x and y coordinates.

filledPolygon(x1,y1,x2,y2, ...)

Prints a closed, filled polygon with no border using alternative x and y coordinates.

curve(x1,y1,x2,y2,x3,y3,x4,y4)

Prints a bezier curve.

filledCurve(x1,y1,x2,y2,x3,y3,x4,y4)

Prints a filled bezier curve without a border.

closedCurve(x1,y1,x2,y2,x3,y3,x4,y4)

Prints an unfilled bezier curve, with the first and last points joined by a straight line.

moveSegment(x,y)

Inserts a move operation (use to start new paths)

lineSegment(x,y)

Inserts a line segment

curveSegment(x,y)

Inserts a curve segment

closePath()

Closes a path

strokePath()

Strokes the path

fillPath()

Fills the path using the non-zero winding number rule

fillStarPath()

Fills the path using the odd-even winding rule (f*, hence the 'star')

fillAndStrokePath()

Fills the path using the non-zero winding number rule and then strokes it

fillStarAndStrokePath()

Fills the path using the odd-even winding rule and then fills it (B*, hence the 'star')

rectangle(x1,y1,xsize,ysize)

Prints an unfilled rectangle.

filledRectangle(x1,y1,xsize,ysize)

Prints a filled rectangle with no border.

FUNCTIONS ^

inch(inches)

Converts inches into points

mm(mms)

Converts millimetres into points

BUGS ^

None known, but the methods do relatively little sanity checking, and there is absolutely no encoding yet for text (so it's probably impossible to print parentheses, for example).

COMING SOON ^

A first stab at encoding text, arrowheads.

PREVIOUS VERSIONS ^

0.04: Consistent capitalisation of methods, generic arbitrary path drawing mechanism. 0.03: Beat module into something approaching standard CPAN shape.

COPYRIGHT AND LICENSE ^

Copyright (C) 2006 by Mark Howe

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: