Professional Web Applications Themes

HTML2PDF on the fly - PHP Development

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 ...

  1. #1

    Default HTML2PDF on the fly

    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.
    ------------------------------------------------------------------------
    K. Guest

  2. Moderated Post

    Default Re: [PHP] HTML2PDF on the fly

    Removed by Administrator
    Burhan Guest
    Moderated Post

  3. #3

    Default Re: [PHP] HTML2PDF on the fly

    This is the error I am getting while executing the script.

    File does not begin with '%PDF-'.

    --
    Thanks & Regards
    Praveen Kumar
    SoftPro Systems Ltd
    On Tue, 2003-11-11 at 16:29, Burhan Khalid wrote: 
    >
    > http://www.fpdf.org
    > http://www.php.net/pdf

    >
    > What error?[/ref]


    -----------------------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.
    ------------------------------------------------------------------------
    K. Guest

  4. #4

    Default Re: [PHP] HTML2PDF on the fly

    Save the file and look at its content, you might have php errors in it.

    K. Praveen Kumar wrote: 
    Marek Guest

Similar Threads

  1. html2pdf ?
    By peter pilsl in forum PERL Modules
    Replies: 0
    Last Post: June 20th, 10:59 AM
  2. html2pdf (htmlDoc.exe) timeout error when there's toomuch data
    By BlueGin101 in forum Macromedia ColdFusion
    Replies: 0
    Last Post: March 10th, 10:35 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139