Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Greetings..I've been trying to get back into using perl, which just means I have more and more questions. I have been trying to use the PDF::API to create some pdfs from some text files. I know there are some converters already outthere, but I would like to just do it myself. This is what I have so far. It's not pretty I know....
#!/usr/bin/perl -w use strict; use PDF::API2; my $counter=0; my @line; my $line; my @files; my $files; my $xc=10; my $yc=780; my $pdf = PDF::API2->new(-file => "test.pdf"); my $page = $pdf->page; my $fnt = $pdf->corefont('Arial',-encode => 'latin1'); my $txt = $page->hybrid; $page->mediabox('LETTER'); $txt->textstart; $txt->font($fnt, 10); my $startdir="x:\\omni\\omni\\surgpref\\"; chdir($startdir); @files = <*.eal>; #.eal are just .txt files, I actually many differen +t extensions, that just designate different people. while ($files[$counter] ne "") { print("Encoding $files[$counter] to PDF format\n"); open(INFILE, "$startdir/$files[$counter]"); $line=<INFILE>; while($line ne "") { $txt->translate($xc,$yc); $yc-=10; if($yc==0){ $pdf->page(); $yc=780; } $txt->text($line); $counter++; $line=<INFILE>; } } $txt->textend; $pdf->save; $pdf->end( );
My problem is this(as far as I know the only one I have so far) after I have created a new page, the text just continues to be written on the first page. What am I missing? I have looked at multiple tutorials and have tried to understand the documentation, but I'm still not understanding how to switch to the next page to begin writing to it... Thanks in advance for you assistance. Bentov

In reply to PDF::API2 is confusing me to death.. by Bentov

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, 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, 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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (5)
    As of 2021-03-04 13:06 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My favorite kind of desktop background is:











      Results (104 votes). Check out past polls.

      Notices?