Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-25 20:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found