Markus Baertschi > PDF-Create-1.06 > PDF::Create

Download:
PDF-Create-1.06.tar.gz

Dependencies

Annotate this POD (3)

Related Modules

PDF::API2
PDF::Labels
PDF::Template
PDF::Reuse
Text::Wrap
CGI::Carp
Compress::Zlib
Win32::OLE
HTML::Template
Class::DBI
more...
By perlmonks.org

CPAN RT

New  2
Open  4
View/Report Bugs
Module Version: 1.06   Source   Latest Release: PDF-Create-1.08

NAME ^

PDF::Create - create PDF files

SYNOPSIS ^

Create PDF output from your perl program using a couple of subroutines to handle text, fonts, images and drawing primitives. Simple documents are easy to create with the supplied routines.

In addition to be reasonable simple PDF::Create is written in pure Perl and has no external dependencies (libraries, other modules, etc.). It should run on any platform where perl is available.

For complex stuff some understanding of the underlying Postscript/PDF format is necessary. In this case it might be better go with the more complete PDF::API2 modules to gain more features at the expense of a steeper learning curve.

Example PDF creation with PDF::Create:

  use PDF::Create;
  # initialize PDF
  my $pdf = new PDF::Create('filename'     => 'mypdf.pdf',
                                        'Author'       => 'John Doe',
                                        'Title'        => 'Sample PDF',
                                        'CreationDate' => [ localtime ], );
                                        
  # add a A4 sized page
  my $a4 = $pdf->new_page('MediaBox' => $pdf->get_page_size('A4'));

  # Add a page which inherits its attributes from $a4
  my $page = $a4->new_page;

  # Prepare a font
  my $f1 = $pdf->font('BaseFont' => 'Helvetica');

  # Prepare a Table of Content
  my $toc = $pdf->new_outline('Title' => 'Title Page', 'Destination' => $page);

  # Write some text
  $page->stringc($f2, 40, 306, 426, "PDF::Create");
  $page->stringc($f1, 20, 306, 396, "version $PDF::Create::VERSION");
  $page->stringc($f1, 20, 306, 300, 'by John Doe <john.doe@example.com>');

  # Add another page
  my $page2 = $a4->new_page;
  
  # Draw some lines
  $page2->line(0, 0, 612, 792);
  $page2->line(0, 792, 612, 0);

  $toc->new_outline('Title' => 'Second Page', 'Destination' => $page2);

  # Close the file and write the PDF
  $pdf->close;

DESCRIPTION ^

PDF::Create allows you to create PDF documents using a number of primitives. The result is as a PDF file or stream.

PDF stands for Portable Document Format.

Documents can have several pages, a table of content, an information section and many other PDF elements.

Methods ^

URI links

URI links have two components, the text or graphics object and the area where the mouseclick should occur.

For the object to be clicked on you'll use standard text of drawing methods.

To define the click-sensitive area and the destination URI you use the annotation() method.

Page methods

Page methods are used to draw stuff on a page. Although these methods are packaged in the separate module PDF::Create::Page you should call them always through the $page handler you get from the new_page() method.

There are internal changes on the horizon who will break code calling methods differently !

Limitations ^

PDF::Create comes with a couple of limitations or known caveats:

PDF Size / Memory

PDF::Create assembles the entire PDF in memory if you create very large documents on a machine with a small amount of memory your program can fail because it runs out of memory.

Small GIF images

Some gif images get created with a minimal lzw code size of less than 8. PDF::Create can not decode those and they must be converted.

Support ^

I support PDF::Create in my spare time between work and family, so the amount of work I put in is limited.

If you experience a problem make sure you are at the latest version first many things have already been fixed.

Please register bug at the CPAN bug tracking system at http://rt.cpan.org or send email to bug-PDF-Create [at] rt.cpan.org

Be sure to include the following information:

- PDF::Create Version you are running

- Perl version (perl -v)

- Operating System vendor and version

- Details about your operating environment that might be related to the issue being described

- Exact cut and pasted error or warning messages

- The shortest, clearest code you can manage to write which reproduces the bug described.

I appreciate patches against the latest released version of PDF::Create which fix the bug.

Feature request can be submitted like bugs. If you provide patch for a feature which does not go against the PDF::Create philosophy (keep it simple) then you have a good chance for it to be accepted.

SEE ALSO ^

Adobe PDF reference http://www.adobe.com/devnet/pdf/pdf_reference.html

My git repository for PDF::Create http://github.com/markusb/pdf-create

Other PDF procesing CPAN modules

http://search.cpan.org/perldoc?PDF::Labels Routines to produce formatted pages of mailing labels in PDF, uses PDF::Create internally

http://search.cpan.org/perldoc?PDF::Haru Perl interface to Haru Free PDF Library

http://search.cpan.org/perldoc?PDF::EasyPDF PDF creation from a one-file module, similar to PDF::Create

http://search.cpan.org/perldoc?PDF::CreateSimple Yet another PDF creation module

http://search.cpan.org/perldoc?PDF::Report A wrapper written for PDF::API2

AUTHORS ^

Fabien Tassin

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

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

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

syntax highlighting: