PDF::Template - Create cascade PDF

Discussion in 'Perl Misc' started by alwaysonnet, Jun 2, 2010.

  1. alwaysonnet

    alwaysonnet Guest

    Hello

    I've been using PDF::Template Module to generate PDF based on my input
    datahash. Please check the working code below

    I want to generate one more set of data in another page without
    changing the XML File. As data comes dynamically I'm not sure of how
    many times I must include the LOOP attribute in my XML File

    Any ideas or suggestions are appreciated.
    Many Thanks

    use strict;
    use PDF::Template;
    my $rpt = new PDF::Template( FILENAME => 'sample.xml' );

    my %Inputs = (
    'svctype' => 'Voice',
    'fromcur' => 'EUR',
    'LOOPDETAIL2' => [
    {
    'seqnum' => 878,
    'date' => '01-Apr-2010',
    'tax' => '0.000',
    'posttax' => '0.000',
    'pretax' => '0.000',
    'israp' => 'FALSE'
    },
    {
    'seqnum' => 879,
    'date' => '02-Apr-2010',
    'tax' => '0.000',
    'posttax' => '0.000',
    'pretax' => '0.000',
    'israp' => 'FALSE'
    },
    {
    'seqnum' => 880,
    'date' => '03-Apr-2010',
    'tax' => '0.000',
    'posttax' => '0.000',
    'pretax' => '0.000',
    'israp' => 'FALSE'
    },
    ],
    'pretax_totals' => '0.000',
    'tax_total' => '0.000',
    'posttax_totals' => '0.000',
    );

    $rpt->param(%Inputs);

    $rpt->write_file('/export/home/kars/sample.pdf');

    Input XML File is as follows

    <pdftemplate name="test">
    <pagedef margins="1i" pagesize="A4" nopagenumber="0">
    <font face="Helvetica" h="10">
    <if name="svctype" op="ne" value="SMS">
    <font face="Helvetica-Bold">
    <row>
    <textbox w="100%" h="*2" text=""/>
    </row>
    <row h="*1.5">
    <textbox w="20%" border="1" justify="center">Date</textbox>
    <textbox w="20%" border="1" justify="center">Sequence Number
    Range</textbox>
    <textbox w="20%" border="1" justify="center">Pre-Tax Value in
    <var name="fromcur"/>
    </textbox>
    <textbox w="20%" border="1" justify="center"> Tax Value
    in <var name="fromcur"/>
    </textbox>
    <textbox w="20%" border="1" justify="center">Post-Tax Value in
    <var name="fromcur"/>
    </textbox>
    </row>
    </font>
    <loop name="LOOPDETAIL2">
    <row h="*1.5">
    <if name="israp" op="eq" value="FALSE">
    <textbox w="20%" border="1" justify="center" text="$date"/>
    <textbox w="20%" border="1" justify="center" text="$seqnum"/>
    <textbox w="20%" border="1" justify="right" text="$pretax"/>
    <textbox w="20%" border="1" justify="right" text="$tax"/>
    <textbox w="20%" border="1" justify="right" text="$posttax"/>
    </if>
    </row>
    </loop>
    <font face="Helvetica-Bold">
    <row h="*1.5">
    <textbox w="20%" border="1" justify="center" text=""/>
    <textbox w="20%" border="1" justify="center" text="Total"/>
    <textbox w="20%" border="1" justify="right"
    text="$pretax_totals"/>
    <textbox w="20%" border="1" justify="right" text="$tax_total"/>
    <textbox w="20%" border="1" justify="right"
    text="$posttax_totals"/>
    </row>
    </font>
    </if>
    </font>
    </pagedef>
    </pdftemplate>
     
    alwaysonnet, Jun 2, 2010
    #1
    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. =?Utf-8?B?d2lsbGlhbQ==?=
    Replies:
    3
    Views:
    2,756
    =?Utf-8?B?d2lsbGlhbQ==?=
    Jan 28, 2005
  2. darrel

    do try/catches cascade?

    darrel, Aug 9, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    404
    darrel
    Aug 10, 2005
  3. Arnold Peters
    Replies:
    1
    Views:
    333
    Sudsy
    Oct 6, 2004
  4. Larry Yondespor

    Hibernate on delete cascade

    Larry Yondespor, Mar 20, 2005, in forum: Java
    Replies:
    2
    Views:
    46,027
    Larry Yondespor
    Mar 20, 2005
  5. Ricardo Pog
    Replies:
    1
    Views:
    454
    Austin Ziegler
    Mar 26, 2008
Loading...

Share This Page