SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Addict
    Join Date
    Aug 2009
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Convert web page

    Hi, I posted about converting a HTML webpage to PDF which from what I have hard is pretty difficult.

    Is there any other formats a page can be converted to, a word document or even just an image in a JPEG or GIF?

    Any suggestions would be brilliant.

    Cheers,

    Paul

  2. #2
    SitePoint Enthusiast facebooklicious's Avatar
    Join Date
    Aug 2009
    Location
    United States
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are many online converters available by which you can convert doc files and image files to any format. Just google it and you will find lot of the.

  3. #3
    PHP Guru lampcms.com's Avatar
    Join Date
    Jan 2009
    Posts
    921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Explain more of your situation. Why do you want to convert web page into pdf or even to an image?

    'pretty difficult' is a relative term. What is pretty difficult for one programmer is just another boring task for another.

  4. #4
    SitePoint Addict
    Join Date
    Aug 2009
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have an invoice system, and I just want it so when an invoice has been created it has a Link that says convert to image, doc or pdf so I can download it to my computer.


  5. #5
    SitePoint Zealot
    Join Date
    Aug 2009
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am using TCPDF to convert HTML to PDF. It works quite well for me.

  6. #6
    SitePoint Addict
    Join Date
    Aug 2009
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is it easy to setup?

  7. #7
    SitePoint Zealot
    Join Date
    Aug 2009
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  8. #8
    SitePoint Addict
    Join Date
    Aug 2009
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, so I have a system where it generates invoices, once the invoice has been generated would TCPDF be able to generate PDF for the generated invoice?

  9. #9
    SitePoint Zealot
    Join Date
    Aug 2009
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, you can convert your HTML invoice into PDF document. I do it this way:

    PHP Code:
        // pdf object
        
    $pdf = new TCPDF();  
        
        
    $pdf->SetCreator(PDF_CREATOR);
        
    $pdf->SetAuthor("Invoicing system");
        
    $pdf->SetTitle("Invoice No 1234");
        
    $pdf->SetSubject("");
        
    $pdf->SetKeywords(""); 
        
        
    // settings
        
    $pdf->SetFont("dejavusans"""10); 
        
        
    // set default header data
        
    $pdf->SetMargins(251525);
        
        
    // don't print header
        
    $pdf->setPrintHeader(false); 
        
        
    // footer
        
    $pdf->setFooterFont(array('dejavusans'''PDF_FONT_SIZE_DATA));
        
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
        
        
    //set auto page breaks
        
    $pdf->SetAutoPageBreak(TRUEPDF_MARGIN_BOTTOM);

        
    //set image scale factor
        
    $pdf->setImageScale(1.7);
        
        
    // init pdf doc
        
    $pdf->AliasNbPages();
        
    $pdf->AddPage();
        
        
    // write HTML
        
    $pdf->writeHTML($htmltrue0true0); 
        
        
    // output
        
    $pdf->Output('invoice-1234.pdf','D'); 
    Note: you need to have your HTML invoice assigned to $html variable.

  10. #10
    SitePoint Addict
    Join Date
    Aug 2009
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, so that is all the PHP I would need to convert the HTML page to PDF? Also, how do I assign the html invoice to $html variable?

    Would I be able to use a button for the PHP so it says 'Save as PDF' or 'Download' ?

    Cheers

  11. #11
    SitePoint Zealot
    Join Date
    Aug 2009
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use this:

    PHP Code:
    $html implode(''file('http://your-site.com/invoice.html')); 
    to get HTML invoice into $html variable.

  12. #12
    SitePoint Addict
    Join Date
    Aug 2009
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, with the file('http:...') this is would only work for the specific domain I would assume?

    The invoice script I use generates the invoice within the same page as the invoice form creator, so it would all be invoice.php, so I would guess that would be a problem.

    Does that make sense?


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
  •