The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

PDF::Haru - Perl interface to Haru Free PDF Library. Haru is a free, cross platform, open-sourced software library for generating PDF.

SYNOPSIS

        use PDF::Haru;

        # create new document
        my $pdf = PDF::Haru::New();

        # add page
        my $page = $pdf->AddPage();

        # set page size and orientation
        $page->SetSize(HPDF_PAGE_SIZE_A4, HPDF_PAGE_PORTRAIT);

        my $font = $pdf->GetFont("Helvetica", "StandardEncoding");
        $page->BeginText();
        $page->SetFontAndSize($font, 20);
        $page->TextOut(40, 781, "text");
        $page->EndText();

        $page->Rectangle (30, 30, $page->GetWidth() - 60, $page->GetHeight() - 60);
        $page->Stroke();

        # save the document to a file
        $pdf->SaveToFile("filename.pdf");

        # cleanup
        $pdf->Free();

METHODS

my $pdf = PDF::Haru::New()

Create an instance of a document object and initialize it.

$pdf->Free()

Revokes a document object and all resources.

$pdf->NewDoc()

Creates new document. If document object already has a document, the current document is revoked.

$pdf->FreeDoc()

Revokes the current document. Keeps loaded resource (such as fonts and encodings) and these resources are recycled when new document required these resources.

$pdf->FreeDocAll()

Revokes the current document and all resources.

$pdf->SaveToFile("filename.pdf")

Saves the current document to a file.

$pdf->SaveAsString()

Returns PDF document as string.

$pdf->SetPagesConfiguration($page_per_pages)

In the default setting, a PDF::Haru object has one "Pages" object as root of pages. All "Page" objects are created as a kid of the "Pages" object. Since a "Pages" object can own only 8191 kids objects, the maximum number of pages are 8191 page.

Additionally, the state that there are a lot of "Page" object under one "Pages" object is not good, because it causes performance degradation of a viewer application.

An application can change the setting of a pages tree by invoking SetPagesConfiguration(). If $page_per_pages parameter is set to more than zero, a two-tier pages tree is created. A root "Pages" object can own 8191 "Pages" object, and each lower "Pages" object can own $page_per_pages "Page" objects. As a result, the maximum number of pages becomes 8191 * $page_per_pages page.

An application cannot invoke SetPageConfiguration() after a page is added to document.

$pdf->SetPageLayout(layout)

Sets how the page should be displayed. If this attribute is not set, the setting of a viewer application is used.

layout is one of following constants

HPDF_PAGE_LAYOUT_SINGLE

Only one page is displayed.

HPDF_PAGE_LAYOUT_ONE_COLUMN

Display the pages in one column.

HPDF_PAGE_LAYOUT_TWO_COLUMN_LEFT

Display the pages in two column. The page of the odd number is displayed left.

HPDF_PAGE_LAYOUT_TWO_COLUMN_RIGHT

Display the pages in two column. The page of the odd number is displayed right.

Example:

$pdf->SetPageLayout(HPDF_PAGE_LAYOUT_ONE_COLUMN)

$pdf->GetPageLayout()

Returns the current setting for page layout.

$pdf->SetPageMode(mode)

Sets how the document should be displayed.

mode is one of following constants

HPDF_PAGE_MODE_USE_NONE

Display the document with neither outline nor thumbnail.

HPDF_PAGE_MODE_USE_OUTLINE

Display the document with outline pain.

HPDF_PAGE_MODE_USE_THUMBS

Display the document with thumbnail pain.

HPDF_PAGE_MODE_FULL_SCREEN

Display the document with full screen mode.

Example:

$pdf->SetPageMode(HPDF_PAGE_MODE_FULL_SCREEN)

$pdf->GetPageLayout()

Returns the current setting for page mode.

$pdf->SetOpenAction($destination)

Set the first page appears when a document is opened. $destination is a destination object created by $page->CreateDestination() function.

my $page = $pdf->GetCurrentPage()

Returns the handle of current page object.

my $page = $pdf->AddPage()

Creates a new page and adds it after the last page of a document.

my $page = $pdf->InsertPage($target)

Creates a new page and inserts it just before the specified page.

$pdf->LoadType1FontFromFile($afmfilename, $pfmfilename)

Loads a type1 font from an external file and register it to a document object. Returns the name of a font.

$afmfilename

A path of an AFM file.

$pfmfilename

A path of a PFA/PFB file. If it is undef, the gryph data of font file is not embedded to a PDF file.

$pdf->LoadTTFontFromFile ($file_name, embedding)

Loads a TrueType font from an external file and register it to a document object. Returns the name of a font.

$file_name

A path of a TrueType font file (.ttf).

embedding

If this parameter is set to HPDF_TRUE, the glyph data of the font is embedded, otherwise only the matrix data is included in PDF file.

$pdf->LoadTTFontFromFile2 ($file_name, $index, embedding)

Loads a TrueType font from an TrueType collection file and register it to a document object. Returns the name of a font.

$file_name

A path of a TrueType font collection file (.ttc).

$index

The index of font that wants to be loaded.

embedding

If this parameter is set to HPDF_TRUE, the glyph data of the font is embedded, otherwise only the matrix data is included in PDF file.

$pdf->AddPageLabel($page_num, style, $first_page, $prefix)

Adds a page labeling range for the document.

$page_num

The first page that applies this labeling range.

style

The numbering style:

HPDF_PAGE_NUM_STYLE_DECIMAL

Page label is displayed by Arabic numerals.

HPDF_PAGE_NUM_STYLE_UPPER_ROMAN

Page label is displayed by Uppercase roman numerals.

HPDF_PAGE_NUM_STYLE_LOWER_ROMAN

Page label is displayed by Lowercase roman numerals.

HPDF_PAGE_NUM_STYLE_UPPER_LETTERS

Page label is displayed by Uppercase letters (using A to Z).

HPDF_PAGE_NUM_STYLE_LOWER_LETTERS

Page label is displayed by Lowercase letters (using a to z).

$first_page

The first page number in this range.

$prefix

The prefix for the page label.

my $font = $pdf->GetFont($font_name, $encoding_name)

Gets the handle of a corresponding font object by specified name and encoding.

$pdf->UseJPFonts()

Enables Japanese fonts. After UseJPFonts() is involed, an application can use the following Japanese fonts.

    * MS-Mincyo
    * MS-Mincyo,Bold
    * MS-Mincyo,Italic
    * MS-Mincyo,BoldItalic
    * MS-Gothic
    * MS-Gothic,Bold
    * MS-Gothic,Italic
    * MS-Gothic,BoldItalic
    * MS-PMincyo
    * MS-PMincyo,Bold
    * MS-PMincyo,Italic
    * MS-PMincyo,BoldItalic
    * MS-PGothic
    * MS-PGothic,Bold
    * MS-PGothic,Italic
    * MS-PGothic,BoldItalic

$pdf->UseKRFonts()

Enables Korean fonts. After UseKRFonts() is involed, an application can use the following Korean fonts.

    * DotumChe
    * DotumChe,Bold
    * DotumChe,Italic
    * DotumChe,BoldItalic
    * Dotum
    * Dotum,Bold
    * Dotum,Italic
    * Dotum,BoldItalic
    * BatangChe
    * BatangChe,Bold
    * BatangChe,Italic
    * BatangChe,BoldItalic
    * Batang
    * Batang,Bold
    * Batang,Italic
    * Batang,BoldItalic

$pdf->UseCNSFonts()

Enables simplified Chinese fonts. After UseCNSFonts() is involed, an application can use the following simplified Chinese fonts.

    * SimSun
    * SimSun,Bold
    * SimSun,Italic
    * SimSun,BoldItalic
    * SimHei
    * SimHei,Bold
    * SimHei,Italic
    * SimHei,BoldItalic

$pdf->UseCNTFonts()

Enables traditional Chinese fonts. After UseCNTFonts() is involed, an application can use the following traditional Chinese fonts.

    * MingLiU
    * MingLiU,Bold
    * MingLiU,Italic
    * MingLiU,BoldItalic

my $encoder = $pdf->GetEncoder($encoding_name)

Gets the handle of a corresponding encoder object by specified encoding name.

my $encoder = $pdf->GetCurrentEncoder()

Gets the handle of the current encoder of the document object. The current encoder is set by invoking SetCurrentEncoder() and it is used to processing a text when an application invoks Info_SetInfoAttr(). The default value of it is undef.

$pdf->SetCurrentEncoder($encoding_name)

Sets the current encoder for the document.

$pdf->UseJPEncodings()

Enables Japanese encodings. After UseJPEncodings() is involed, an application can use the following Japanese encodings.

    * 90ms-RKSJ-H
    * 90ms-RKSJ-V
    * 90msp-RKSJ-H
    * EUC-H
    * EUC-V

$pdf->UseKREncodings()

Enables Korean encodings. After UseKREncodings() is involed, an application can use the following Korean encodings.

    * KSC-EUC-H
    * KSC-EUC-V
    * KSCms-UHC-H
    * KSCms-UHC-HW-H
    * KSCms-UHC-HW-V

$pdf->UseCNSEncodings()

Enables simplified Chinese encodings. After UseCNSEncodings() is involed, an application can use the following simplified Chinese encodings.

    * GB-EUC-H
    * GB-EUC-V
    * GBK-EUC-H
    * GBK-EUC-V

$pdf->UseCNTEncodings()

Enables traditional Chinese encodings. After UseCNTEncodings() is involed, an application can use the following traditional Chinese encodings.

    * GB-EUC-H
    * GB-EUC-V
    * GBK-EUC-H
    * GBK-EUC-V

my $outline = $pdf->CreateOutline($parent,$title,$encoder)

Creates a new outline object.

$parent

The handle of an outline object which comes to the parent of the created outline object. If undef, the outline is created as a root outline.

$title

The caption of the outline object.

$encoder

The handle of an encoding object applied to the title. If undef, PDFDocEncoding is used.

my $image = $pdf->LoadPngImageFromFile($filename)

Loads an external png image file and returns image object.

my $image = $pdf->LoadPngImageFromFile2($filename)

Loads an external png image file and returns image object. Unlike LoadPngImageFromFile(), LoadPngImageFromFile2() does not load whole data immediately. (only size and color properties is loaded). The main data is loaded just before the image object is written to PDF, and the loaded data is deleted immediately.

my $image = $pdf->LoadJpegImageFromFile($filename)

Loads an external Jpeg image file and returns image object.

$pdf->SetInfoAttr (type, $value)

SetInfoAttr() sets the text of the info dictionary. SetInfoAttr() uses the current encoding of the document.

type

The following values are available.

    HPDF_INFO_AUTHOR
    HPDF_INFO_CREATOR
    HPDF_INFO_TITLE
    HPDF_INFO_SUBJECT
    HPDF_INFO_KEYWORDS
$value

A text to set the infomation.

$pdf->GetInfoAttr (type)

Gets an attribute value from info dictionary.

type

The following values are available.

    HPDF_INFO_CREATION_DATE
    HPDF_INFO_MOD_DATE
    HPDF_INFO_AUTHOR
    HPDF_INFO_CREATOR
    HPDF_INFO_TITLE
    HPDF_INFO_SUBJECT
    HPDF_INFO_KEYWORDS 

$pdf->SetInfoDateAttr(type,$year,$month,$day,$hour,$minutes,$seconds,$ind,$off_hour,$off_minutes)

Sets a datetime attribute in the info dictionary.

type

One of the following attributes:

    HPDF_INFO_CREATION_DATE
    HPDF_INFO_MOD_DATE 
$year,$month,$day,$hour,$minutes,$seconds,$ind,$off_hour,$off_minutes

The new value for the attribute.

        $year   
        $month  Between 1 and 12.
        $day    Between 1 and 28, 29, 30, or 31. (Depends on the month.)
        $hour   0 to 23
        $minutes        0 to 59
        $seconds        0 to 59
        $ind    Relationship of local time to Universal Time (" ", +, −, or Z).
        $off_hour       If "ind" is not space, 0 to 23 is valid. Otherwise, ignored.
        $off_minutes    If "ind" is not space, 0 to 59 is valid. Otherwise, ignored. 

$pdf->SetPassword ($owner_passwd, $user_passwd)

Sets the pasword for the document. If the password is set, contents in the document are encrypted.

$owner_password

The password for the owner of the document. The owner can change the permission of the document. Zero length string and the same value as user password are not allowed.

$user_password

The password for the user of the document. The $user_password is allowed to be set to zero length string.

$pdf->SetPermission(permission)

Set the flags of the permission for the document.

permission flags specifying which operations are permitted. This parameter is set by logical addition of the following values.

HPDF_ENABLE_READ

user can read the document.

HPDF_ENABLE_PRINT

user can print the document.

HPDF_ENABLE_EDIT_ALL

user can edit the contents of the document other than annotations, form fields.

HPDF_ENABLE_COPY

user can copy the text and the graphics of the document.

HPDF_ENABLE_EDIT

user can add or modify the annotations and form fields of the document.

Example:

$pdf->SetPermission(PDF_ENABLE_READ+PDF_ENABLE_PRINT)

$pdf->SetEncryptionMode(mode, $key_len)

Set the type of encryption. As the side effect, SetEncryptionMode() ups the version of PDF to 1.4 when the mode is set to PDF_ENCRYPT_R3.

mode

The flags specifying which operations are permitted. This parameter is set by logical addition of the following values.

HPDF_ENCRYPT_R2

Use "Revision 2" algorithm. The length of key is automatically set to 5(40bit).

HPDF_ENCRYPT_R3

Use "Revision 3" algorithm. Between 5(40bit) and 16(128bit) can be specified for length of the key.

$key_len

Specify the byte length of an encryption key. This parameter is valid only when "mode" parameter is set to PDF_ENCRYPT_R3. Between 5(40bit) and 16(128bit) can be specified for length of the key.

$pdf->SetCompressionMode(mode)

mode flags specifying which type of contents should be compressed.

HPDF_COMP_NONE

All contents are not compressed.

HPDF_COMP_TEXT

Compress the contents stream of the page.

HPDF_COMP_IMAGE

Compress the streams of the image objects.

HPDF_COMP_METADATA

Other stream datas (fonts, cmaps and so on) are compressed.

HPDF_COMP_ALL

All stream datas are compressed. (The same as "PDF_COMP_TEXT + PDF_COMP_IMAGE + PDF_COMP_METADATA")

Example:

$pdf->SetCompressionMode(PDF_COMP_TEXT+PDF_COMP_METADATA)

$page->SetWidth($value)

Changes the width of a page. The valid value is between 3 and 14400.

$page->SetHeight($value)

Changes the height of a page. The valid value is between 3 and 14400.

$page->SetSize(size, direction)

Changes the size and direction of a page to a predefined size.

size

Specify a predefined page-size value. The following values are available.

        HPDF_PAGE_SIZE_LETTER
        HPDF_PAGE_SIZE_LEGAL
        HPDF_PAGE_SIZE_A3
        HPDF_PAGE_SIZE_A4
        HPDF_PAGE_SIZE_A5
        HPDF_PAGE_SIZE_B4
        HPDF_PAGE_SIZE_B5
        HPDF_PAGE_SIZE_EXECUTIVE
        HPDF_PAGE_SIZE_US4x6
        HPDF_PAGE_SIZE_US4x8
        HPDF_PAGE_SIZE_US5x7
        HPDF_PAGE_SIZE_COMM10
direction

Specify the direction of the page.

        HPDF_PAGE_PORTRAIT
        HPDF_PAGE_LANDSCAPE

$page->SetRotate($angle)

Sets rotation angle of the page. Angle must be a multiple of 90 Degrees.

$page->GetWidth()

Gets the width of a page.

$page->GetHeight()

Gets the height of a page.

my $destination = $page->CreateDestination()

Creates a new destination object for the page.

my $annotation = $page->CreateTextAnnot($text,$encoder,$left,$bottom,$right,$top)

Creates a new text annotation object for the page.

$text

The text to be displayed.

$encoder

An encoder handle which is used to encode the text. If it is undef, PDFDocEncoding is used.

$left,$bottom,$right,$top

A Rectangle where the annotation is displayed.

my $annotation = $page->CreateLinkAnnot($dst,$left,$bottom,$right,$top)

Creates a new link annotation object for the page.

$dst

A handle of destination object to jump to.

$left,$bottom,$right,$top

Rectangle of clickable area.

my $annotation = $page->CreateURILinkAnnot($uri,$left,$bottom,$right,$top)

Creates a new link annotation object for the page.

$uri

URL of destination to jump to.

$left,$bottom,$right,$top

Rectangle of clickable area.

$page->TextWidth($text)

Gets the width of the text in current fontsize, character spacing and word spacing.

$page->MeasureText ($text, $width, wordwrap)

Calculates the byte length which can be included within the specified width.

$text

The text to get width.

$width

The width of the area to put the text.

wordwrap

When there are three words of "ABCDE", "FGH", and "IJKL", and the substring until "J" can be included within the width, if wordwrap parameter is HPDF_FALSE it returns 12, and if wordwrap parameter is HPDF_TRUE it returns 10 (the end of the previous word).

$page->GetGMode()

Gets the current graphics mode.

my ($x, $y) = $page->GetCurrentPos()

Gets the current position for path painting.

my ($x, $y) = $page->GetCurrentTextPos()

Gets the current position for text showing.

my $font = $page->GetCurrentFont()

Gets the handle of the page's current font.

$page->GetCurrentFontSize()

Gets the size of the page's current font.

my ($a,$b,$c,$d,$x,$y) = $page->GetTransMatrix()

Gets the current transformation matrix of the page.

$page->GetLineWidth()

Gets the current line width of the page.

$page->GetLineCap()

Gets the current line cap style of the page.

$page->GetLineJoin()

Gets the current line join style of the page.

$page->GetMiterLimit()

Gets the current value of the page's miter limit.

my ($dash_pattern,$phase) = $page->GetDash()

Gets the current pattern of the page.

$page->GetFlat()

Gets the current value of the page's flatness.

$page->GetCharSpace()

Gets the the current value of the page's character spacing.

$page->GetWordSpace()

Returns the current value of the page's word spacing.

$page->GetHorizontalScalling()

Returns the current value of the page's horizontal scalling for text showing.

$page->GetTextLeading()

Returns the current value of the page's line spacing.

$page->GetTextRenderingMode()

Returns the current value of the page's text rendering mode.

$page->GetTextRise()

Returns the current value of the page's text rising.

my ($r, $g, $b) = $page->GetRGBFill()

Returns the current value of the page's filling color.

my ($r, $g, $b) = $page->GetRGBStroke()

Returns the current value of the page's stroking color.

my ($c, $m, $y, $k) = $page->GetCMYKFill()

Returns the current value of the page's filling color.

my ($c, $m, $y, $k) = $page->GetCMYKStroke()

Returns the current value of the page's stroking color.

$page->GetGrayFill()

Returns the current value of the page's filling color.

$page->GetGrayStroke()

Returns the current value of the page's stroking color.

$page->GetStrokingColorSpace()

Returns the current value of the page's stroking color space.

$page->GetFillingColorSpace()

Returns the current value of the page's stroking color space.

$page->GetTextMatrix()

Gets the current text transformation matrix of the page.

$page->GetGStateDepth()

Returns the number of the page's graphics state stack.

$page->SetSlideShow(type,$disp_time,$trans_time)

Configures the setting for slide transition of the page.

type

The transition style. The following values are available.

    HPDF_TS_WIPE_RIGHT
    HPDF_TS_WIPE_UP
    HPDF_TS_WIPE_LEFT
    HPDF_TS_WIPE_DOWN
    HPDF_TS_BARN_DOORS_HORIZONTAL_OUT
    HPDF_TS_BARN_DOORS_HORIZONTAL_IN
    HPDF_TS_BARN_DOORS_VERTICAL_OUT
    HPDF_TS_BARN_DOORS_VERTICAL_IN
    HPDF_TS_BOX_OUT
    HPDF_TS_BOX_IN
    HPDF_TS_BLINDS_HORIZONTAL
    HPDF_TS_BLINDS_VERTICAL
    HPDF_TS_DISSOLVE
    HPDF_TS_GLITTER_RIGHT
    HPDF_TS_GLITTER_DOWN
    HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT
    HPDF_TS_REPLACE 
$disp_time

The display duration of the page. (in seconds)

$trans_time

The duration of the transition effect. Default value is 1(second).

$page->Arc($x, $y, $ray, $ang1, $ang2)

Appends a circle to the current path.

$x, $y

The center point of the circle.

$ray

The ray of the circle.

$ang1

The angle of the begining of the arc.

$ang2

The angle of the end of the arc. It must be greater than ang1.

$page->BeginText()

Begins a text object and sets the current text position to the point (0, 0).

$page->Circle($x,$y,$ray)

Appends a circle to the current path.

$x, $y

The center point of the circle.

$ray

The ray of the circle.

$page->Clip()

$page->ClosePath()

Appends a strait line from the current point to the start point of sub path. The current point is moved to the start point of sub path.

$page->ClosePathStroke()

Closes the current path, then it paints the path.

$page->ClosePathEofillStroke()

Closes the current path, fills the current path using the even-odd rule, then it paints the path.

$page->ClosePathFillStroke()

Closes the current path, fills the current path using the nonzero winding number rule, then it paints the path.

$page->Concat($a, $b, $c, $d, $x, $y)

Concat() concatenates the page's current transformation matrix and specified matrix.

        # save the current graphics states
        $page->GSave ();

        # concatenate the transformation matrix
        $page->Concat (0.7, 0.3, -0.4, 0.6, 220, 350);

        # show text on the translated coordinates
        $page->BeginText ();
        $page->MoveTextPos (50, 100);
        $page->ShowText ("Text on the translated coordinates");
        $page->EndText ();

        # restore the graphics states 
        $page->GRestore ();
$a, $b, $c, $d, $x, $y

The transformation matrix to concatenate.

$page->CurveTo($x1,$y1,$x2,$y2,$x3,$y3)

Appends a Bézier curve to the current path using two spesified points. The point ($x1, $y1) and the point ($x2, $y2) are used as the control points for a Bézier curve and current point is moved to the point ($x3, $y3)

$page->CurveTo2($x2,$y2,$x3,$y3)

Appends a Bézier curve to the current path using two spesified points. The current point and the point ($x2, $y2) are used as the control points for a Bézier curve and current point is moved to the point ($x3, $y3)

$page->CurveTo3($x1,$y1,$x3,$y3)

Appends a Bézier curve to the current path using two spesified points. The point ($x1, $y1) and the point ($x3, $y3) are used as the control points for a Bézier curve and current point is moved to the point ($x3, $y3)

$page->DrawImage($image,$x,$y,$width,$height)

Shows an image in one operation.

$image

The handle of an image object.

$x, $y

The lower-left point of the region where image is displayed.

$width

The width of the region where image is displayed.

$height

The width of the region where image is displayed.

$page->Ellipse($x, $y, $xray, $yray)

Appends an ellipse to the current path.

$x, $y

The center point of the circle.

$xray, $yray

The radius in the x and y direction.

$page->EndPath()

Ends the path object without filling and painting operation.

$page->EndText()

Ends a text object.

$page->Eoclip()

$page->Eofill()

Fills the current path using the even-odd rule.

$page->EofillStroke()

Fills the current path using the even-odd rule, then it paints the path.

$page->Fill()

Fills the current path using the nonzero winding number rule.

$page->FillStroke()

Fills the current path using the nonzero winding number rule, then it paints the path.

$page->GRestore()

Restore the graphics state which is saved by GSave().

$page->GSave()

Saves the page's current graphics parameter to the stack. An application can invoke GSave() up to 28 and can restore the saved parameter by invoking GRestore().

The parameters that are saved by GSave() is as follows.

    * Transformation Matrix
    * Line Width
    * Line Cap Style
    * Line Join Style
    * Miter Limit
    * Dash Mode
    * Flatness
    * Character Spacing
    * Word Spacing
    * Horizontal Scalling
    * Text Leading
    * Rendering Mode
    * Text Rise
    * Filling Color
    * Stroking Color
    * Font
    * Font Size

$page->LineTo($x,$y)

Appends a path from the current point to the specified point.

$page->MoveTextPos($x,$y)

Moves the current text position to the start of the next line with using specified offset values. If the start position of the current line is (x1, y1), the start of the next line is (x1 + $x, y1 + $y).

$page->MoveTextPos2($x,$y)

Moves the current text position to the start of the next line with using specified offset values, and sets the text-leading to -y. If the start position of the current line is (x1, y1), the start of the next line is (x1 + $x, y1 + $y).

$page->MoveTo($x,$y)

Sets the start point for the path to the point.

$page->MoveToNextLine()

Moves the current text position to the start of the next line. If the start position of the current line is (x1, y1), the start of the next line is (x1, y1 - text leading). NOTE: Since the default value of Text Leading is 0, an application have to invoke SetTextLeading() before MoveToNextLine() to set text leading.

$page->Rectangle($x,$y,$width,$height)

Appends a rectangle to the current path.

$x,$y

The lower-left point of the rectangle.

$width

The width of the rectangle.

$height

The height of the rectangle.

$page->SetCharSpace($value)

Sets the character spacing for text showing. The initial value of character spacing is 0.

$page->SetCMYKFill($c,$m,$y,$k)

Sets the filling color. $c,$m,$y,$k - the level of each color element. They must be between 0 and 1.

$page->SetCMYKStroke($c,$m,$y,$k)

Sets the stroking color. $c,$m,$y,$k - the level of each color element. They must be between 0 and 1.

$page->SetDash(\@dash_pattern,$phase)

Sets the line dash pattern in the page.

\@dash_pattern

Pattern of dashes and gaps used to stroke paths.

$phase

The phase in which the pattern begins (default is 0).

Example:

$page->SetDash([8, 7, 2, 7], 0);

$page->SetExtGState($ext_gstate)

Applys the graphics state to the page.

$ext_gstate

The handle of a extended graphics state object.

$page->SetGrayFill($gray)

Sets the filling color. The value of the gray level between 0 and 1.

$page->SetGrayStroke($gray)

Sets the stroking color. The value of the gray level between 0 and 1.

$page->SetFontAndSize($font,$size)

Sets the type of font and size leading.

$font

The handle of a font object.

$size

The size of a font.

$page->SetHorizontalScalling($value)

Sets the horizontal scalling for text showing. The initial value of horizontal scalling is 100.

$page->SetLineCap(line_cap)

line_cap The style of line-cap:

PDF_BUTT_END

The line is squared off at the endpoint of the path.

PDF_ROUND_END

The end of a line becomes a semicircle whose center is the end point of the path.

PDF_PROJECTING_SCUARE_END

The line continues to the point that exceeds half of the stroke width the end point.

$page->SetLineJoin(line_join)

Sets the line join style in the page. line_join The style of line-join.

        HPDF_MITER_JOIN
        HPDF_ROUND_JOIN
        HPDF_BEVEL_JOIN

$page->SetLineWidth($line_width)

Sets the width of the line used to stroke a path.

$page->SetMiterLimit($miter_limit)

$page->SetRGBFill($r, $g, $b)

Sets the filling color. $r, $g, $b - the level of each color element. They must be between 0 and 1.

$page->SetRGBStroke($r, $g, $b)

Sets the stroking color. $r, $g, $b - the level of each color element. They must be between 0 and 1.

$page->SetTextLeading($value)

Sets the text leading (line spacing) for text showing. The initial value of leading is 0.

$page->SetTextMatrix($a,$b,$c,$d,$x,$y)

$page->SetTextRenderingMode(mode)

Sets the text rendering mode. The initial value of text rendering mode is HPDF_FILL.

mode one of the following values

        HPDF_FILL
        HPDF_STROKE
        HPDF_FILL_THEN_STROKE
        HPDF_INVISIBLE
        HPDF_FILL_CLIPPING
        HPDF_STROKE_CLIPPING
        HPDF_FILL_STROKE_CLIPPING
        HPDF_CLIPPING

$page->SetTextRise($value)

Moves the text position in vertical direction by the amount of value. Useful for making subscripts or superscripts.

$value

Text rise, in user space units.

$page->SetWordSpace($value)

Sets the word spacing for text showing. The initial value of word spacing is 0.

$page->ShowText($text)

Prints the text at the current position on the page.

$page->ShowTextNextLine($text)

Moves the current text position to the start of the next line, then prints the text at the current position on the page.

$page->ShowTextNextLineEx($word_space, $char_space, $text)

Moves the current text position to the start of the next line, then sets the word spacing, character spacing and prints the text at the current position on the page.

$page->Stroke()

Paints the current path.

$page->TextOut($xpos, $ypos, $text)

Prints the text on the specified position.

$xpos, $ypos

The point position where the text is displayed.

$text

The text to show.

$page->TextRect($left, $top, $right, $bottom, $text, align)

Print the text inside the specified region.

$left, $top, $right, $bottom

Coordinates of corners of the region to output text.

$text

The text to show.

align

The alignment of the text. One of the following values

        HPDF_TALIGN_LEFT
        HPDF_TALIGN_RIGHT
        HPDF_TALIGN_CENTER
        HPDF_TALIGN_JUSTIFY

$font->GetFontName()

Gets the name of the font.

$font->GetEncodingName()

Gets the encoding name of the font.

$font->GetUnicodeWidth($code)

Gets the width of a Unicode character in a specific font.

my ($left, $bottom, $right, $top) = $font->GetBBox($code)

Gets the bounding box of the font.

$font->GetAscent()

Gets the vertical ascent of the font.

$font->GetDescent()

Gets the vertical descent of the font.

$font->GetXHeight()

Gets the distance from the baseline of lowercase letters.

$font->GetCapHeight()

Gets the distance from the baseline of uppercase letters.

my ($numchars, $numwords, $width, $numspace) = $font->TextWidth($text,$len)

Gets total width of the text, number of characters, and number of words.

$text

The text to get width.

$len

The byte length of the text.

$font->MeasureText($text,$len,$width,$font_size,$char_space,$word_space,$wordwrap)

Calculates the byte length which can be included within the specified width.

$text

The text to use for calculation.

$len

The length of the text.

$width

The width of the area to put the text.

$font_size

The size of the font.

$char_space

The character spacing.

$word_space

The word spacing.

$wordwrap

Suppose there are three words: "ABCDE", "FGH", and "IJKL". Also, suppose the substring until "J" can be included within the width (12 bytes). If word_wrap is HPDF_TRUE the function returns 12. If word_wrap parameter is HPDF_FALSE, it returns 10 (the end of the previous word).

$annotation->LinkAnnot_SetHighlightMode(mode)

Defines the appearance when a mouse clicks on a link annotation.

mode - One of the following values:

        HPDF_ANNOT_NO_HIGHTLIGHT        No highlighting.
        HPDF_ANNOT_INVERT_BOX   Invert the contents of the area of annotation.
        HPDF_ANNOT_INVERT_BORDER        Invert the annotation's border.
        HPDF_ANNOT_DOWN_APPEARANCE      Dent the annotation. 

$annotation->LinkAnnot_SetBorderStyle($width,$dash_on,$dash_off)

Defines the style of the annotation's border.

$width

The width of an annotation's border.

$dash_on,$dash_off

The dash style.

$annotation->TextAnnot_SetIcon(icon)

Defines the appearance when a mouse clicks on a link annotation.

icon - The style of icon. The following values are available.

    HPDF_ANNOT_ICON_COMMENT
    HPDF_ANNOT_ICON_KEY
    HPDF_ANNOT_ICON_NOTE
    HPDF_ANNOT_ICON_HELP
    HPDF_ANNOT_ICON_NEW_PARAGRAPH
    HPDF_ANNOT_ICON_PARAGRAPH
    HPDF_ANNOT_ICON_INSERT 

$annotation->TextAnnot_SetOpened($open)

Defines whether the text-annotation is initially open.

$open

HPDF_TRUE means the annotation initially displayed open.

$outline->SetOpened($opened)

Sets whether this node is opened or not when the outline is displayed for the first time. $opened specify whether the node is opened or not.

$outline->SetDestination($dst)

Sets a destination object which becomes to a target to jump when the outline is clicked. $dst specify the handle of an destination object.

$destination->SetXYZ($left,$top,$zoom)

Defines the appearance of a page with three parameters which are left, top and zoom.

$left

The left coordinates of the page.

$top

The top coordinates of the page.

$zoom

The page magnified factor. The value must be between 0.08(8%) to 32(%).

$destination->SetFit()

Sets the appearance of the page to displaying entire page within the window.

$destination->SetFitH($top)

Defines the appearance of a page to magnifying to fit the width of the page within the window and setting the top position of the page to the value of the "top" parameter.

$top

The top coordinates of the page.

$destination->SetFitV($left)

Defines the appearance of a page to magnifying to fit the height of the page within the window and setting the left position of the page to the value of the "top" parameter.

$left

The left coordinates of the page.

$destination->SetFitR($left,$bottom,$right,$top)

Defines the appearance of a page to magnifying the page to fit a rectangle specified by left, bottom, right and top.

$left

The left coordinates of the page.

$bottom

The bottom coordinates of the page.

$right

The right coordinates of the page.

$top

The top coordinates of the page.

$destination->SetFitB()

Sets the appearance of the page to magnifying to fit the bounding box of the page within the window.

$destination->SetFitBH($top)

Defines the appearance of a page to magnifying to fit the width of the bounding box of the page within the window and setting the top position of the page to the value of the "top" parameter.

$top

The top coordinates of the page.

$destination->SetFitBV($top)

Defines the appearance of a page to magnifying to fit the height of the bounding box of the page within the window and setting the top position of the page to the value of the "top" parameter.

$top

The top coordinates of the page.

my ($x,$y) = $image->GetSize()

Gets the size of the image of an image object.

$image->GetWidth()

Gets the width of the image of an image object.

$image->GetHeight()

Gets the height of the image of an image object.

$image->GetBitsPerComponent()

Gets the number of bits used to describe each color component.

$image->GetColorSpace()

Gets the name of the image's color space. It returns the following values

        "DeviceGray"
        "DeviceRGB"
        "DeviceCMYK"
        "Indexed"

$image->SetColorMask ($rmin, $rmax, $gmin, $gmax, $bmin, $bmax)

Sets the transparent color of the image by the RGB range values. The color within the range is displayed as a transparent color. The Image must be RGB color space.

$rmin

The lower limit of Red. It must be between 0 and 255.

$rmax

The upper limit of Red. It must be between 0 and 255.

$gmin

The lower limit of Green. It must be between 0 and 255.

$gmax

The upper limit of Green. It must be between 0 and 255.

$bmin

The lower limit of Blue. It must be between 0 and 255.

$bmax

The upper limit of Blue. It must be between 0 and 255.

$image->SetMaskImage($mask_image)

Sets the mask image.

$mask_image specify the handle of an image object which is used as image-mask. This image must be 1bit gray-scale color image.

SEE ALSO

http://libharu.org/

AUTHOR

Ilya Butakov, butilw@gmail.com

COPYRIGHT AND LICENSE

Copyright (C) 2008 by Ilya Butakov

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.8 or, at your option, any later version of Perl 5 you may have available.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 913:

Non-ASCII character seen before =encoding in '−,'. Assuming UTF-8