Hi all,
     Can anybody tell me how can I convert the HTML to PDF on the fly. I
have a HTML form which should be converted into PDF after filling and
submitting it. Please give me your valuable suggestions. I have been
using HTMLDOC-1.8.23.

executing the below code giving error.This code is given in HTMLDOC.

<?php

function topdf($filename, $options = "") {
    # Write the content type to the client...
        header("Content-Type: application/pdf");
    flush();
    # Run HTMLDOC to provide the PDF file to the user...
        passthru("htmldoc --no-localfiles --no-compression -t pdf14 --quiet
--jpeg --webpage "."$options $filename");
}


//
// 'bad_url()' - See if the URL contains bad characters...
//

function bad_url($url) {
    // See if the URL starts with http: or https:...
    if (strncmp($url, "http://";, 7) != 0 &&
        strncmp($url, "https://";, 8) != 0) {
        return 1;
    }

    // Check for bad characters in the URL...
    $len = strlen($url);
    for ($i = 0; $i < $len; $i ++) {
        if (!strchr("~_*()/:%?+-&@;=,$.", $url[$i]) &&
            !ctype_alnum($url[$i])) {
            return 1;
        }
    }

    return 0;
}

//
// MAIN ENTRY - Pass the trailing path info in to HTMLDOC...
//

global $SERVER_NAME;
global $SERVER_PORT;
global $PATH_INFO;
global $QUERY_STRING;

if ($QUERY_STRING != "") {
    $url = "${QUERY_STRING}";
        //$url=http://${SERVER_NAME}:${SERVER_PORT}${PATH_INFO}?${QUERY_STRING}
} else {
    $url = "http://${SERVER_NAME}:${SERVER_PORT}$PATH_INFO";;
}

if (bad_url($url)) {
  print("<HTML><HEAD><TITLE>Bad URL</TITLE></HEAD>\n"
       ."<BODY><H1>Bad URL</H1>\n"
       ."<P>The URL <B><TT>$url</TT></B> is bad.</P>\n"
       ."</BODY></HTML>\n");
} else {
  topdf($url);
}
?>
-- 
Thanks & Regards
Praveen Kumar
SoftPro Systems Ltd

-----------------------SOFTPRO DISCLAIMER------------------------------

Information contained in this E-MAIL and any attachments are
confidential being  proprietary to SOFTPRO SYSTEMS  is 'privileged'
and 'confidential'.

If you are not an intended or authorised recipient of this E-MAIL or
have received it in error, You are notified that any use, copying or
dissemination  of the information contained in this E-MAIL in any
manner whatsoever is strictly prohibited. Please delete it immediately
and notify the sender by E-MAIL.

In such a case reading, reproducing, printing or further dissemination
of this E-MAIL is strictly prohibited and may be unlawful.

SOFTPRO SYSYTEMS does not REPRESENT or WARRANT that an attachment
hereto is free from computer viruses or other defects. 

The opinions expressed in this E-MAIL and any ATTACHEMENTS may be
those of the author and are not necessarily those of SOFTPRO SYSTEMS.
------------------------------------------------------------------------

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to