Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 524
  • Last Modified:

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

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
phishee
Asked:
phishee
1 Solution
 
kanduraCommented:
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
 
rj2Commented:
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
 
mattaustinCommented:
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
 
jmcgOwnerCommented:
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now