help me with perl script that creat pdf


 
Thread Tools Search this Thread
Top Forums Programming help me with perl script that creat pdf
# 1  
Old 10-20-2011
help me with perl script that creat pdf

Hi,
I have one xml file, I extracted some comments and saved in pdf file.I written code like this
Code:
#!/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 ("unable to open file");
     my %nums;
 while ($reader->nextElement( 'Number' ) ) {
  
	my $number = $reader->readInnerXml();
	
	$reader->nextElement( 'address' ); 

	my $info = $reader->readOuterXml(); 

$nums{$number}= $info;
 }
 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');

when I run this code it extracting and printing extracted tags as it is in pdf file like as shown below.
Code:
$VAR1 = '24';
$VAR2 = '<Address>
<housenumber="120"/>
<streetname="xxx"/>
    </information>';
$VAR3 = '25';
$VAR4 = '<Address>
<housenumber="150"/>
<streetname="xxx"/>
    </information>';
$VAR5 = '27';
$VAR6 = '<Address>
<housenumber="140"/>
<streetname="xxx"/>
    </information>';

like that but i need to print data in pdf like this
Code:
number: 24
Information:Address,
                 housenumber="120",
                  streetname="xxx". 
number: 25
Information:Address,
                 housenumber="150",
                  streetname="xxx". 
number: 27
Information:Address,
                 housenumber="140",
                  streetname="xxx".

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.
# 2  
Old 10-20-2011
Why not ask this in your original thread?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl to extract from a pdf

The below perl script produces the metrics.txt below using the run.txt as the input. perl -ne 'BEGIN{print join("\t","R_Index", "ISP Loading", "Pre-Enrichment", "Total Reads", "Read Length", "Key Signal", "Usable Sequence", "Enrichment", "Polyclonal" ,"Low Quality" ,"Test Fragment", "Aligned... (2 Replies)
Discussion started by: cmccabe
2 Replies

2. Shell Programming and Scripting

Converting secured pdf files to pdf using acroread

Does anybody have idea of Converting secured pdf files to pdf using acroread ? ---------- Post updated at 04:49 PM ---------- Previous update was at 04:44 PM ---------- This file is not password protected. (4 Replies)
Discussion started by: Soham
4 Replies

3. Shell Programming and Scripting

PDF Script to extract PDF Links MOD in Need

In here we have a script to extract all pdf links from a single page.. any idea's in how make this read instead of a page a list of pages.. and extract all pdf links ? #!/bin/bash # NAME: pdflinkextractor # AUTHOR: Glutanimate (http://askubuntu.com/users/81372/), 2013 #... (1 Reply)
Discussion started by: danielldf
1 Replies

4. Shell Programming and Scripting

Perl program to convert PDF to text/CSV

Please suggest ways to easily convert pdf to text in perl only on windows (no other tools can be downloaded) Here is what I have been doing : using a module CAM::PDF to extract data. But it shows everything in messy format :wall: But this module is the only one working with the pdf... (0 Replies)
Discussion started by: chakrapani
0 Replies

5. Debian

creat image for the new kernel

Hello friends, I have compiled the kernel . But now i am facing the problem as to how we can create the initrd.img for the specific kernel. I was compiling the 2.6.29 kernel. to create initrd.img for 2.6.29 what i did is : cd /boot mkinitramfs-kpkg -o initrd.img-2.6.29 2.6.29... (2 Replies)
Discussion started by: pradeepreddy
2 Replies

6. Shell Programming and Scripting

Perl - Convert html to pdf - PDF::FromHTML

Hi, I am trying to convert html to pdf using perl module PDF::FromHTML, am getting the error as given below. not well-formed (invalid token) at line 2, column 17, byte 56 at C:/Perl/lib/XML/Parser.pm line 187 at C:/Perl/site/lib/PDF/FromHTML.pm line 140 The perl code is as given... (2 Replies)
Discussion started by: DILEEP410
2 Replies

7. Shell Programming and Scripting

Converting html to pdf perl

Hi All, I have a requirement of converting an html form into pdf using perl. The html form contains images, tables and css implementation. I tried using various perl modules but failed to achive the target. I succeeded in generating a pdf from the html file using... (2 Replies)
Discussion started by: DILEEP410
2 Replies

8. Solaris

creat flash archive

I want take a flash backup by flar command for specific files like: / , /boot, /tmp I am trying this command but its not working # flar -n archive1 -f /,/boot,/tmp -F -c /home/arc1.flar Please can any body help me __.____._ (2 Replies)
Discussion started by: kmuqalled
2 Replies

9. Programming

Creat-Crontab

Dear All, Please any send the idea and designing for creating the crontab in c Thank in advanced (2 Replies)
Discussion started by: dhinesh
2 Replies
Login or Register to Ask a Question