View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Markus Baertschi > PDF-Create-1.06 > PDF::Create



Annotate this POD (3)

Related Modules



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


PDF::Create - create PDF files


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 <>');

  # 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::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 or send email to bug-PDF-Create [at]

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.


Adobe PDF reference

My git repository for PDF::Create

Other PDF procesing CPAN modules Routines to produce formatted pages of mailing labels in PDF, uses PDF::Create internally Perl interface to Haru Free PDF Library PDF creation from a one-file module, similar to PDF::Create Yet another PDF creation module A wrapper written for PDF::API2


Fabien Tassin

GIF and JPEG-support: Michael Gross (

Maintenance since 2007: Markus Baertschi (


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: