veerubiji has asked for the wisdom of the Perl Monks concerning the following question:
when I run this code it extracting and printing extracted tags as it is in pdf file like as shown below.#!/usr/bin/perl use warnings; use strict; use PDF::API2; use PDF::API2::Page; use XML::LibXML::Reader; use Data::Dumper; my $file; open( $file, 'formal.xml'); my $reader = XML::LibXML::Reader->new( IO => $file ) or die ("unab +le to open file"); my %nums; while ($reader->nextElement( 'Number' )) { my $number = $reader->copyCurrentNode(1)->textContent; $reader->nextElement( 'address' ); my $node = $reader->copyCurrentNode(1); my $infohash = { house => $node->getElementsByTagName( 'housenumber' )[0]->tex +tContent, street => $node->getElementsByTagName( 'streetname' )[0]->tex +tContent, }; $nums{$number} = $infohash; } "syntax error here "}" my $pdf = PDF::API2->new(); # $pdf->mediabox('Letter'); my $font = $pdf->corefont('Times-Roman'); my $page = $pdf->page(); $page->mediabox('Letter'); my $cnt=0; for my $line (split /\n/, Dumper(%nums)) { if ($cnt > 46) { $page = $pdf->page(); $cnt=0; } my $text = $page->text(); $text->font($font,14); $text->translate(72, 720-$cnt*14); $text->text($line); ++$cnt; } $pdf->saveas('svr.pdf');
like that but i need to print data in pdf like this$VAR1 = '24'; $VAR2 = '<Address> <housenumber="120"/> <streetname="xxx"/> </Address>'; $VAR3 = '25'; $VAR4 = '<Address> <housenumber="150"/> <streetname="xxx"/> </Address>'; $VAR5 = '27'; $VAR6 = '<Address> <housenumber="140"/> <streetname="xxx"/> </Address>';
I need to print output like this in pdf file. In my Written code I am printing xml tags as it is. What should i do to print like, help me with script. I cahnged little bit and i am getting syntax errors at " ")[" near and "}" before pdf starts.number: 24, address information of the student. Information:Address, housenumber="120", streetname="xxx". number: 25, address information of the student. Information:Address, housenumber="150", streetname="xxx". number: 27, address information of the student. Information:Address, housenumber="140", streetname="xxx".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl script to print data like this in pdf.
by roboticus (Chancellor) on Oct 20, 2011 at 15:09 UTC | |
by veerubiji (Sexton) on Oct 21, 2011 at 08:17 UTC | |
by roboticus (Chancellor) on Oct 21, 2011 at 10:15 UTC | |
|
Re: perl script to print data like this in pdf.
by choroba (Cardinal) on Oct 20, 2011 at 15:09 UTC | |
|
Re: perl script to print data like this in pdf.
by afoken (Chancellor) on Oct 21, 2011 at 08:30 UTC |