Good day,

I just started using PDF::Create and it works very well. I do have two particular needs that I can't figure out from the documentation or anywhere else I've looked. I can create a .pdf document very easily. What I'd like to do is write over the same file.

Let me explain. Using an applicant tracking system I built (all in Perl and on our Intranet) I'd like to have the ability to print out a summary of an application for the individuals to sign so we can have it on file. Since we've got all the information stored in the DB, we shouldn't have to save a .pdf for each candidate. I'd rather create one on the fly and print it and be done with it. Then when I come to the next candidate, just overwrite the existing .pdf and print. Here's the code from the sample.pl that comes with the Module:

#!/usr/bin/perl -w BEGIN { unshift @INC, "lib", "../lib" } use strict; use PDF::Create; my $pdf = new PDF::Create('filename' => '/html/mypdf.pdf', 'Version' => 1.2, 'PageMode' => 'UseNone', 'Author' => 'Ovaltine', 'Title' => 'Anything', ); my $root = $pdf->new_page('MediaBox' => [ 0, 0, 612, 792 ]); # Add a page which inherits its attributes from $root my $page = $root->new_page; # Prepare 2 fonts my $f1 = $pdf->font('Subtype' => 'Type1', 'Encoding' => 'WinAnsiEncoding', 'BaseFont' => 'Helvetica'); my $f2 = $pdf->font('Subtype' => 'Type1', 'Encoding' => 'WinAnsiEncoding', 'BaseFont' => 'Helvetica-Bold'); # Prepare a Table of Content my $toc = $pdf->new_outline('Title' => 'Document', 'Destination' => $page); $page->stringc($f2, 40, 306, 626, "PDF::Create 2"); $page->stringc($f1, 20, 306, 596, "version $PDF::Create::VERSION") +; # Add another page my $page2 = $root->new_page; $page2->stringc($f1, 20, 306, 400, 'Let us see what is on page 2.' +); $page2->line(40, 40, 572, 40); $page2->line(40, 752, 572, 752); # Add something to the first page $page->stringc($f1, 20, 306, 400, 'by Ovaltine <bellybuster@thebar +.com>'); $page->stringc($f1, 15, 306, 350, 'More text for the reading.'); # Add the missing PDF objects and a the footer then close the file $pdf->close;

My only idea so far is to have Perl delete the file before it creates on (of the same name). Any ideas?

Also, I've learned how to draw lines (thanks to the example) but I can't figure out how to draw rectangles and shaded boxes. I haven't been able to find a good example to build from. The docs give the verbage but I can't seem to get anywhere. Help!

TIA

peppiv

"flying blind on a rocket cycle!"


In reply to PDF::Create Questions by peppiv

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.