Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I wrote a PDF module a long time ago and have been using it for personal use. Recently I added html-like tables( has column and row spanning) to it and a few other items. Actually, I keep adding to it as I see reason to. A friend wanted to use it to create bi-lingual Biblical text and so I added unicode support and embeded TrueType fonts(which was lots of fun). You see I had to use iText (java) extensively at work, but really wanted something vastly easier to use for Perl, so I developed my own both as an exercise in learning the PDF Spec better and some Perl OOP. It's only real dependancy is Compress::Zlib. If you want to try it let me know. I call it MoosePdf, silly I know. But I gave it a really terse yet simple and IMHO intuitive syntax. For instance, one way to do the above program with just the raw text and image operators (with a table it would simpler) would be thus:
use strict; use DBI; use MoosePdf; my $pdf = new MoosePdf('myPdf.pdf'); my $page = $pdf->addPage(size=>'595x852', margins=> 72); my $f = $page->addFont("Helvetica"); my $fb = $page->addFont("Helvetica-Bold"); my $image = $page->addImage(file=>"santa.jpg"); #path my $height = $image->getHeight; $page->showImage( image=>$image, x=>100, y=> 100+$height); $page->addText( text=>"Heading Here", x=>100, y=>100, font=>$fb, size= +> 10 ); my $dbh=DBI->connect("DBI:mysql:database=voice:host=localhost","userna +me","password") or die "$!\n"; my $sth=$dbh->prepare("select column1,column2,column3,column4,column5 +from test") or die "$!\n"; $sth->execute() or die "$!\n"; my $y = 750; while (my @row=$sth->fetchrow_array()) { $y -= 45; my $string=join(",",@row)."\n"; $page->addText( text=>$string, x=>100, y=>$y, font=>$f, size=> 10 ); if( $y < 100 ){ $page = $pdf->AddPage(); #inherits from existing page $page->addText(text=>"Heading Here", font=>$fb, size=>10, x=>100, y +=>800 ); $y = 750; } } $pdf->save();

Anyway, if you want to try it, msg me with your email and I will send it and some examples to you if you will agree to not redistribute it as it needs more documentation.

JamesNC

In reply to Re^2: Putting text and images in PDFs using PDF::API2 by JamesNC
in thread Putting text and images in PDFs using PDF::API2 by leighsharpe

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 avoiding work at the Monastery: (4)
As of 2024-04-16 05:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found