Solved

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

Posted on 2003-11-10
5
511 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Perl program to obtain a machine's memory usage 6 22
perl to display a matrix report for 3-dimenional array 3 67
perl split by | 2 97
batch script for automated email 12 109
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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 …
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 tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

785 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