Top Questions

  • 5.11 Years

    • Category : Php
    • Location : Chandigarh, India
    • Posted On : Jan 10, 2018

    Now generate 'A5' sized PDF from html and display it view. The PDF name will be 'simple_any_name.pdf'.

    <?php
     // INCLUDE THE phpToPDF.php FILE
    require("phpToPDF.php"); 
    
    // PUT YOUR HTML IN A VARIABLE
    $my_html="<HTML>
    <h2>Test HTML 02</h2><br><br>
    <div style=\"display:block; padding:20px; border:2pt solid:#FE9A2E; background-color:#F6E3CE; font-weight:bold;\">
    phpToPDF is pretty cool! <br><br>
    [This was orange, but I set the PDF option to monochrome (Black & White)]
    </div><br><br>
    For more examples, visit us here --> https://www.dorcode.com/
    </HTML>";
    
    // SET YOUR PDF OPTIONS -- FOR ALL AVAILABLE OPTIONS, VISIT HERE:  http://phptopdf.com/documentation/
    $pdf_options = array(
      "source_type" => 'html',
      "source" => $my_html,
      "action" => 'view',
      "color" => 'monochrome',
      "page_orientation" => 'landscape',
      "file_name" => 'simple_any_name.pdf');
    
    // CALL THE phpToPDF FUNCTION WITH THE OPTIONS SET ABOVE
    phptopdf($pdf_options);
    
    ?> 
     

Add Your Answer

When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.