Results 1 to 6 of 6

Thread: Pdf format

  1. #1
    Join Date
    Aug 2009
    Posts
    74
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default Pdf format

    name designation experience
    -------- ----------- ------------
    xxxx LEADER 4 years (for more information view,HTML,download pdf)
    xxx DESIGNER fresher (for more information view,HTML,download pdf)
    aaa MANAGER 10 years (for more information view,HTML,download pdf)
    abcs PROGRAMMER 12 months(for more information view,HTML,download pdf)

    now my problem is, name designation experience all these i can get it through database. but what i want is, code for downloading more information through pdf format or to view as html.PLEASE IF THERE IS ANY ONE WHO KNOW THIS PLEASE HELP ME

  2. #2
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    Unfortunately,it's not as simple as one little snippet of code to do what you want.

    First you'll need to have the library installed on your server [html2pdf].
    http://sourceforge.net/projects/html2fpdf/files/

    If you're running it on a hosted server that belongs to a host provider, ask them to install it for you. If they're cool,they'll do it.

    From there, use this code:
    PHP Code:
    <?php   
      
    $html
    "<h1>hello</h1>";  //To add more html code use $html.= yourcode; in the next line  
      
    define('HTML2FPDF_VERSION','3.0(beta)');  
    define('RELATIVE_PATH','fpdf/');  
    define('FPDF_FONTPATH','font/');  
      
    require_once(
    RELATIVE_PATH.'fpdf.php');  
    require_once(
    RELATIVE_PATH.'htmltoolkit.php');  
    require_once(
    RELATIVE_PATH.'html2fpdf.php');  
    $pdf = new HTML2FPDF();  
    $pdf->WriteHTML($html);  
    $name="doc.pdf";  
    $pdf->Output($name);  
      
    ?>
    It's very self explanatory.$html is the html to convert to pdf format. Now, since you're using a database, you'll need to first create the html w/the data values, and THEN use the $html var to declare it.

    When downloading the library, it'll give you a further explanation on how to do it. I don't think there's any online documentation for you to use.

    HTH
    - Josh

  3. The Following User Says Thank You to JShor For This Useful Post:

    hemi (08-20-2009)

  4. #3
    Join Date
    Aug 2009
    Posts
    74
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default

    now iam able to open pdf file but when i click on download option to save or open a alert box comes and it displays

    __________________________________________________________________________

    acrobat pdf can no t be open create.pdf because it is either not a supported file type or because the file has corrupted (for example it was sent as an email attachement and wasn't correctly decoded).

    To create an Adobe PDF document, go to the source application,then print the document to adobe PDF
    __________________________________________________________________________



    my code is




    echo"select * from registrationform where id=$_REQUEST[id]";
    $gotten =mysql_query("select * from registrationform where id=$_REQUEST[id]");
    $row = mysql_fetch_assoc($gotten);
    $bytes = $row['event_picture'];
    header("Content-type: application/pdf");
    header("Content-disposition: attachment; filename=$bytes");


    please help me

  5. #4
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    OK, the file name must be a created file, it can't be a variable.

    This is not correct, and will NOT work:
    PHP Code:
    <?php

    $bytes 
    $row['event_picture'];
    header("Content-type: application/pdf");
    header("Content-disposition: attachment; filename=$bytes");

    ?>
    You will have to create a file, have it downloaded, and then optionally delete it when the download completes.

    PHP Code:
    <?php

    $file 
    "create.pdf";
    $fh fopen($file'w') or die("Cannot create file");

    $bytes $row['event_picture'];

    fwrite($fh$bytes);
    fclose($fh);

    header("Content-type: application/pdf");
    header("Content-disposition: attachment; filename=$file");

    ?>
    - Josh

  6. The Following User Says Thank You to JShor For This Useful Post:

    hemi (08-20-2009)

  7. #5
    Join Date
    Aug 2009
    Posts
    74
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default

    thnk u now i am getting it

  8. #6
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    She needs to create it on the fly, using PHP.
    - Josh

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
  •