dynamic content with PDF::API2

Discussion in 'Perl Misc' started by ccc31807, Aug 8, 2012.

  1. ccc31807

    ccc31807 Guest

    I've been using PDF::API2 for years without a problem of any kind, but now have a new requirement -- text wrapping. Here's an example:

    #from a hashref from a database, name could be NULL
    my $name = $hashref->{$key}{name};
    my $sentence = '';
    $sentence = "Hello, my name is $name." if $name;

    #in PDF code
    $text->text("Greetings. $sentence Here is some information.");

    This works if $name is NULL, because $sentence takes up no space and the end result contains two spaces after the greeting, which isn't a big deal.

    However, there's a big difference between 'Ed' and 'Barack Hussein Obama.' The longer names cause the line to run off the right margin.

    Is it possible to wrap text in PDF::API2? I've looked and can't see how.

    I could write my own wrapping routine, but would rather not.

    I also don't want to use another module (maybe CAM::pDF) but would rather not, and I haven't looked at the other modules to see if they can wrap text.

    Thanks, CC.
     
    ccc31807, Aug 8, 2012
    #1
    1. Advertising

  2. ccc31807

    ccc31807 Guest

    On Sunday, August 12, 2012 2:02:04 PM UTC-4, Ben Morrow wrote:
    > Doing text wrapping properly is Hard. If you care about the quality of
    > your output you ought to be using a proper typesetting program like TeX.
    > (Modern versions of TeX, LuaTeX and ConTeXt in particular, are much less
    > gnarly than they used to be, especially when it comes to using ordinary
    > fonts.) You could also consider generating something you can feed
    > through InDesign or <spit> Word.


    Thanks, Ben. Yes, wrapping is hard. All I've ever done is placing fixed sized objects on a PDF, and since the main requirement has been uniform appearance of the PDF, PDF::API2 has worked out real well for me.

    I am very fond of LaTeX and am known locally as an evangelist of LaTeX, but I like things real simple, and using the suggested alternatives (not by you) such as printing to RTF or DOCX and so on cost much more than the benefit.

    As much as I hate to, I'm going to tell my user that he has to modify his layout to accommodate my inability to wrap his text. Fortunately and unusually, he is tech savvy and understands why, so it won't be a problem.

    Thank God for understanding users, CC.
     
    ccc31807, Aug 13, 2012
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. michael vernersen

    Perl::API2 PDF problem.

    michael vernersen, Feb 29, 2004, in forum: Perl Misc
    Replies:
    0
    Views:
    110
    michael vernersen
    Feb 29, 2004
  2. michael vernersen

    perl::api2 pdf problem...

    michael vernersen, Feb 29, 2004, in forum: Perl Misc
    Replies:
    5
    Views:
    133
    michael vernersen
    Mar 3, 2004
  3. Bruce Horrocks
    Replies:
    0
    Views:
    434
    Bruce Horrocks
    Jan 24, 2006
  4. Ted Byers
    Replies:
    3
    Views:
    159
    Peter J. Holzer
    Dec 17, 2008
  5. Jasper2000

    PDF::API2 (Creating PDF files)

    Jasper2000, Mar 11, 2010, in forum: Perl Misc
    Replies:
    1
    Views:
    324
    Jasper2000
    Mar 11, 2010
Loading...

Share This Page