NAME

PDF::Create::Page - PDF pages tree for PDF::Create

VERSION

Version 1.45

DESCRIPTION

FOR INTERNAL USE ONLY

METHODS

add($id, $name)

Adds a page to the PDF document.

count()

Returns page count.

kids()

Returns ref to a list of page ids.

list()

Returns page list.

new_page()

Return new page.

moveto($x, $y)

Moves the current point to (x, y), omitting any connecting line segment.

lineto($x, $y)

Appends a straight line segment from the current point to (x, y).

curveto($x1, $y1, $x2, $y2, $x3, $y3)

Appends a Bezier curve to the path. The curve extends from the current point to (x3 ,y3) using (x1 ,y1) and (x2 ,y2) as the Bezier control points.The new current point is (x3 ,y3).

rectangle($x, $y, $w, $h)

Adds a rectangle to the current path.

closepath()

Closes the current subpath by appending a straight line segment from the current point to the starting point of the subpath.

newpath()

Ends the path without filling or stroking it.

stroke()

Strokes the path.

closestroke()

Closes and strokes the path.

fill()

Fills the path using the non-zero winding number rule.

fill2()

Fills the path using the even-odd rule.

line($x1, $y1, $x2, $y2)

Draw a line between ($x1, $y1) and ($x2, $y2). Combined moveto / lineto / stroke command.

set_width($w)

Set the width of subsequent lines to w points.

setgray($value)

Sets the color space to DeviceGray and sets the gray tint to use for filling paths.

setgraystroke($value)

Sets the color space to DeviceGray and sets the gray tint to use for stroking paths.

setrgbcolor($r, $g, $b)

Sets the fill colors used for normal text or filled objects.

setrgbcolorstroke($r, $g, $b)

Set the color of the subsequent drawing operations. Valid r, g, and b values are each between 0.0 and 1.0, inclusive.

Each color ranges from 0.0 to 1.0, i.e., darkest red (0.0) to brightest red(1.0). The same holds for green and blue. These three colors mix additively to produce the colors between black (0.0, 0.0, 0.0) and white (1.0, 1.0, 1.0).

PDF distinguishes between the stroke and fill operations and provides separate color settings for each.

text(%params)

Renders the text. Parameters are explained as below:

+--------+------------------------------------------------------------------+
| Key    | Description                                                      |
+--------+------------------------------------------------------------------+
| start  | The start marker, add directive BT                               |
| end    | The end marker, add directive ET                                 |
| text   | Text to add to the pdf                                           |
| F      | Font index to be used, add directive /F<font_index>              |
| Tf     | Font size for the text, add directive <font_size> Tf             |
| Ts     | Text rise (super/subscript), add directive <mode> Ts             |
| Tr     | Text rendering mode, add directive <mode> Tr                     |
| TL     | Text leading, add directive <number> TL                          |
| Tc     | Character spacing, add directive <number> Tc                     |
| Tw     | Word spacing, add directive <number> Tw                          |
| Tz     | Horizontal scaling, add directive <number> Tz                    |
| Td     | Move to, add directive <x> <y> Td                                |
| TD     | Move to and set TL, add directive <x> <y> TD                     |
| rot    | Move to and rotate (<r> <x> <y>), add directive                  |
|        | <cos(r)>, <sin(r)>, <sin(r)>, <cos(r)>, <x>, <y> Tm              |
| T*     | Add new line.                                                    |
+--------+------------------------------------------------------------------+

string($font, $size, $x, $y, $text $alignment)

Add text to the current page using the font object at the given size and position. The point (x, y) is the bottom left corner of the rectangle containing the text.

The optional alignment can be 'r' for right-alignment and 'c' for centered.

Example :

my $f1 = $pdf->font(
   'Subtype'  => 'Type1',
   'Encoding' => 'WinAnsiEncoding',
   'BaseFont' => 'Helvetica'
);

$page->string($f1, 20, 306, 396, "some text");

string_underline($font, $size, $x, $y, $text, $alignment)

Draw a line for underlining.The parameters are the same as for the string function but only the line is drawn. To draw an underlined string you must call both,string and string_underline. To change the color of your text use the setrgbcolor(). It returns the length of the string. So its return value can be used directly for the bounding box of an annotation.

Example :

$page->string($f1, 20, 306, 396, "some underlined text");

$page->string_underline($f1, 20, 306, 396, "some underlined text");

stringl($font, $size, $x, $y $text)

Same as string().

stringr($font, $size, $x, $y, $text)

Same as string() but right aligned (alignment 'r').

stringc($font, $size, $x, $y, $text)

Same as string() but centered (alignment 'c').

string_width($font, $text)

Return the size of the text using the given font in default user space units.This does not contain the size of the font yet, to get the length you must multiply by the font size.

printnl($text, $font, $size, $x, $y)

Similar to string() but parses the string for newline and prints each part on a separate line. Lines spacing is the same as the font-size.Returns the number of lines.

Note the different parameter sequence.The first call should specify all parameters, font is the absolute minimum, a warning will be given for the missing y position and 800 will be assumed. All subsequent invocations can omit all but the string parameters.

ATTENTION:There is no provision for changing pages.If you run out of space on the current page this will draw the string(s) outside the page and it will be invisible.

block_text(\%params)

Add block of text to the page. Parameters are explained as below:

+------------+--------------------------------------------------------------+
| Key        | Description                                                  |
+------------+--------------------------------------------------------------+
| page       | Object of type PDF::Create::Page                             |
| font       | Font index to be used.                                       |
| text       | Text block to be used.                                       |
| font_size  | Font size for the text.                                      |
| text_color | Text color as arrayref i.e. [r, g, b]                        |
| line_width | Line width (in points)                                       |
| start_y    | First row number (in points) when adding new page.           |
| end_y      | Last row number (in points) when to add new page.            |
| x          | x co-ordinate to start the text.                             |
| y          | y co-ordinate to start the text.                             |
+------------+--------------------------------------------------------------+

use strict; use warnings;
use PDF::Create;

my $pdf  = PDF::Create->new('filename'=>"$0.pdf", 'Author'=>'MANWAR', 'Title'=>'Create::PDF');
my $root = $pdf->new_page('MediaBox' => $pdf->get_page_size('A4'));
my $page = $root->new_page;
my $font = $pdf->font('BaseFont' => 'Helvetica');

$page->rectangle(30, 780, 535, 40);
$page->setrgbcolor(0,1,0);
$page->fill;

$page->setrgbcolorstroke(1,0,0);
$page->line(30, 778, 565, 778);

$page->setrgbcolor(0,0,1);
$page->string($font, 15, 102, 792, 'MANWAR - PDF::Create');

my $text = qq{
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into ele-It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions
};

$page->block_text({
    page       => $page,
    font       => $font,
    text       => $text,
    font_size  => 6,
    text_color => [0,0,1],
    line_width => 535,
    start_y    => 780,
    end_y      => 60,
    'x'        => 30,
    'y'        => 770,
});

$pdf->close;

image(%params)

Inserts an image. Parameters can be:

+----------------+----------------------------------------------------------+
| Key            | Description                                              |
+----------------+----------------------------------------------------------+
|                |                                                          |
| image          | Image id returned by PDF::image (required).              |
|                |                                                          |
| xpos, ypos     | Position of image (required).                            |
|                |                                                          |
| xalign, yalign | Alignment of image.0 is left/bottom, 1 is centered and 2 |
|                | is right, top.                                           |
|                |                                                          |
| xscale, yscale | Scaling of image. 1.0 is original size.                  |
|                |                                                          |
| rotate         | Rotation of image.0 is no rotation,2*pi is 360° rotation.|
|                |                                                          |
| xskew, yskew   | Skew of image.                                           |
|                |                                                          |
+----------------+----------------------------------------------------------+

Example jpeg image:

# include a jpeg image with scaling to 20% size
my $jpg = $pdf->image("image.jpg");

$page->image(
    'image'  => $jpg,
    'xscale' => 0.2,
    'yscale' => 0.2,
    'xpos'   => 350,
    'ypos'   => 400
);

AUTHORS

Fabien Tassin

GIF and JPEG-support: Michael Gross (info@mdgrosse.net)

Maintenance since 2007: Markus Baertschi (markus@markus.org)

Currently maintained by Mohammad S Anwar (MANWAR) <mohammad.anwar at yahoo.com>

REPOSITORY

https://github.com/manwar/pdf-create

COPYRIGHT

Copyright 1999-2001,Fabien Tassin.All rights reserved.It may be used and modified freely, but I do request that this copyright notice remain attached to the file. You may modify this module as you wish,but if you redistribute a modified version, please attach a note listing the modifications you have made.

Copyright 2007 Markus Baertschi

Copyright 2010 Gary Lieberman

LICENSE

This is free software; you can redistribute it and / or modify it under the same terms as Perl 5.6.0.