Results 1 to 6 of 6

Thread: Apache2 and Perl with modules PDF::API2 & MIME::Lite (Creating a PDF Document)

  1. #1

    Default Apache2 and Perl with modules PDF::API2 & MIME::Lite (Creating a PDF Document)

    Hope someone can point me in the right Direction or help with a problem / lack of knowledge.

    SuSE Linux 12.1 64bit

    Apache2, Perl and the PDF::API2 & MIME::Lite modules installed.

    Simplistic cgi script created so far:

    #!/usr/bin/perl

    use PDF::API2;
    use MIME::Lite;

    ### Create PDF Document
    my $pdf = PDF::API2->new(-file => "../htdocs/invoices/invoice.pdf");
    $pdf->mediabox(595,842);
    my $page = $pdf->page;
    my $fnt = $pdf->corefont('Arial',-encoding => 'latin1');
    my $txt = $page;
    $pdf->saveas ('../htdocs/invoices/invoice-$Number.pdf';

    ### Mailing Data
    my $from_address = 'mai1test@otherdomainname.co.uk';
    my $to_address = 'admin@mydomainname.co.uk';

    ### Adjust subject and body message
    my $subject = 'eInvoice blah';
    my $message_body = "Please find attached your invoice, blah, blah";

    ### Adjust the filenames
    my $path = '../htdocs/invoices/';
    my $attachment = 'invoice-$Number.pdf';

    ### Create the multipart container
    $msg = MIME::Lite->new (
    From => $from_address,
    To => $to_address,
    Subject => $subject,
    Type =>'multipart/mixed'
    ) or die "Error creating multipart container: $!\n";

    ### Add the text message part
    $msg->attach (
    Type => 'TEXT',
    Data => $message_body
    ) or die "Error adding the text message part: $!\n";

    ### Add the PDF Document
    $msg->attach (
    Type => 'application/pdf',
    Path => $path,
    Filename => $attachment,
    Disposition => 'attachment'
    ) or die "Error adding $file_gif: $!\n";

    ### Send the Message
    $msg->send;

    this successfully creates the pdf document and then sends it off as an attachment in an email.

    At the mo i have a html webform for entering user data that is sent to a cgi script, the script formats the data does a few sums then prints to screen a html page for printing, a html email is sent to myself and to the person entering the data.

    I would like to learn how to take that same data from the webform and use images to create a pdf document that can then be sent as an attachment in an email.

    Can someone help or recommend a website or two where i may find more info and get help.

    Mark

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,157

    Default Re: Apache2 and Perl with modules PDF::API2 & MIME::Lite (Creating a PDF Document)

    I assume that you have written the PHP script above with a more telling lay-out then we see. Please use the appropriate wrappers to post these sorts of things. That is CODE wrappers for "neutral" computer text anf PHP wrappers for PHP. THis is a description for CODE, but PHP is a few icons further in there: http://forums.opensuse.org/english/i...ags-guide.html

    (BTW it is openSUSE, not SuSE Linux).
    Henk van Velden

  3. #3

    Default Re: Apache2 and Perl with modules PDF::API2 & MIME::Lite (Creatinga PDF Document)

    hcvv wrote:
    > I assume that you have written the PHP script


    It isn't PHP, it is perl, as the title says

  4. #4

    Default Re: Apache2 and Perl with modules PDF::API2 & MIME::Lite (Creatinga PDF Document)

    akwe-xavante wrote:
    > Can someone help or recommend a website or two where i may find more
    > info and get help.


    This is a perl question rather than an opensuse question, so you're
    likely to get more answers on a perl site such as http://www.perlmonks.org/

    e.g. http://www.perlmonks.org/?node=pdf

  5. #5
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,157

    Default Re: Apache2 and Perl with modules PDF::API2 & MIME::Lite (Creatinga PDF Document)

    Quote Originally Posted by djh-novell View Post
    hcvv wrote:
    > I assume that you have written the PHP script


    It isn't PHP, it is perl, as the title says
    I appologize. Even I should be able to see of something is PHP or not
    Henk van Velden

  6. #6

    Default Re: Apache2 and Perl with modules PDF::API2 & MIME::Lite (Creatinga PDF Document)

    Thank you everybody for your help.

    I'll look elsewhere for help with this, at least for now i have fresh servers installed with the new OS and all related packages and modules and i've proved so far that the perl modules are working.

    I just need to find out / learn how to use imported data and images into a respectable PDF document now, using perl and perls PDF::API2 module

    That's going to be fun, does anybody know where i can bulk buy copious amounts of Valium!?

    Thank you again

    Mark

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •