My Perl / cgi script gets data from the webform in this way

The script gets data from a webform then prints back to the browser, creates a PDF Document and sends an email with the PDF document as an attachment

The script is long so i've only printed what i think you'l need here - i hope

#!/usr/bin/perl use strict; use CGI ':standard'; use PDF::API2; use MIME::Lite; use utf8; $Name = param('name'); $Email = param('email'); $Subject = param('subject'); $Contents = param('contents');

If the users data entered into the variable $Contents contains spaces between lines or paragraphs, these blank lines are removed somewhere during the process of printing it back to the browsers screen and into a PDF Document and the email

Simplistically its printed back to the browser:

print "Content-Type:text/html\n\n"; <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.or +g/TR/xhtml11/DTD/xhtml11.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\"> <head></head> <body> <p>Thank you $Name for your message entitled $Subject</p> <br> <p>Your Message was:</p> <br /> <p>$Contents</p> <br /> <p>I will contact you as soon as possible if a response is required.</ +p> <br /> <h2>$MyName</h2> <br /> <br /> <br /> </body </html>

And Printed into the PDF Document:

$txt->font($fnt, 8); $txt->translate(25,740); $txt->fillcolor('black'); $txt->text("$Contents");

And added to an email:

my $Message = " <p>Thank you $Name for your email.</p> <p>Subject: $Subject</p> <p>Your Message was:</p> <p>$Contents</p> "; my $msg = MIME::Lite->new ( From => $From, To => $To, Subject => "Subject: re: $Subject", Type =>'multipart/mixed' ) or die "Error creating multipart container: $!\n"; ###### Add the text message part # $msg->attach ( Type => 'HTML', Data => "$Message", ) or die "Error adding the text message part: $!\n"; ##### Send the Message $msg->send;

In reply to Re^2: Formatting Input by akwe-xavante
in thread Formatting Input by akwe-xavante

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.