Solved

convert/export Perl output to a PDF for online viewing and retrieval

Posted on 2003-11-10
5
508 Views
Last Modified: 2012-06-22
I have co-authored a Perl script which parses a log file (a content-filtering log of sites visited and banned) and now I would like to export the output to a PDF for easy user retrieval.  Is is possible to do directly from the Perl or how could I use a PHP function like ezPDF to take the outputted (HTML) page and convert it to PDF format?

Thanks in advance for any and all advice/tips/help

Brandon (phishee)
0
Comment
Question by:phishee
5 Comments
 
LVL 18

Expert Comment

by:kandura
ID: 9717054
Although I haven't used them myself yet, I know that there are a number of Perl modules you can use. PDF::API2, PDF::Report, PDF::Reuse are some I've seen. PDF::Template looks promising, as it allows you to write a template in xml, and then fill it with data using perl.

For all available modules, have a look at http://search.cpan.org and search for pdf.

HTH,
Kandura
0
 
LVL 10

Accepted Solution

by:
rj2 earned 200 total points
ID: 9717061
Here is link to module that can create PDF files.
http://search.cpan.org/~ftassin/PDF-Create-0.01/

But why do you want to make results from parsing log files into PDF, can't users just as easily retrieve a plain text file?
PDF files are usually used for documents with embedded graphics where preserving exact layout is important.
That is usually not the case for log files.
0
 
LVL 2

Expert Comment

by:mattaustin
ID: 9725338
PDF::Create is the way to go! works great!

    use PDF::Create;

    my $pdf = new PDF::Create('filename' => 'mypdf.pdf',
                              'Version'  => 1.2,
                              'PageMode' => 'UseOutlines',
                              'Author'   => 'Fabien Tassin',
                              'Title'    => 'My title',
                         );
    my $root = $pdf->new_page('MediaBox'  => [ 0, 0, 612, 792 ]);

    # Add a page which inherits its attributes from $root
    my $page = $root->new_page;

    # Prepare 2 fonts
    my $f1 = $pdf->font('Subtype'  => 'Type1',
                            'Encoding' => 'WinAnsiEncoding',
                         'BaseFont' => 'Helvetica');
    my $f2 = $pdf->font('Subtype'  => 'Type1',
                         'Encoding' => 'WinAnsiEncoding',
                         'BaseFont' => 'Helvetica-Bold');

    # Prepare a Table of Content
    my $toc = $pdf->new_outline('Title' => 'Document',
                                'Destination' => $page);
    $toc->new_outline('Title' => 'Section 1');
    my $s2 = $toc->new_outline('Title' => 'Section 2', 'Status' => 'closed');
    $s2->new_outline('Title' => 'Subsection 1');

    $page->stringc($f2, 40, 306, 426, "PDF::Create");
    $page->stringc($f1, 20, 306, 396, "version $PDF::Create::VERSION");

    # Add another page
    my $page2 = $root->new_page;
    $page2->line(0, 0, 612, 792);
    $page2->line(0, 792, 612, 0);

    $toc->new_outline('Title' => 'Section 3');
    $pdf->new_outline('Title' => 'Summary');

    # Add something to the first page
    $page->stringc($f1, 20, 306, 300, 'by Fabien Tassin <fta@oleane.net>');

    # Add the missing PDF objects and a the footer then close the file
    $pdf->close;
0
 
LVL 20

Expert Comment

by:jmcg
ID: 10089867
Nothing has happened on this question in more than 8 weeks. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
accept answer by rj2.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
perl exit code 2 245
Excel to CSV conversion with specific columns 5 68
Writing a parser for java language 4 61
Perl tar error 8 32
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now