Save html file as PDF

I use the PHP output buffer to create the HTML file of the Dynamic Data Overview page, then save that output as an HTML file on the server and would like to create a PDF file of this HTML file (stored on the server), but every solution I looked at requires so that you enter the HTML in the variable, but I have a .HTML file that I want to convert to PDF automatically, but cannot find a solution.

The general idea here is to provide the user with a “copy” of the email data review, so I suggested that the PDF file would be the best, but if there are any other suggestions, I would love to consider something else.

Any help would be greatly appreciated.

Thank!

+6
source share
2 answers

I was strongly looking for creating PDF files in PHP, and here is what I found in a few years ...


PDF Conversion Tools

  • FPDF

    • This option is really good if you want to generate a PDF file using the PDF method (I will use it because you are literally generating the PDF file in parts).

      • Features include:

        • Select unit, page format, and margins
        • Page header and footer management
        • Auto page break
        • Auto line break and text alignment
        • Image Support (JPEG, PNG, and GIF)
        • Colour
        • References
        • TrueType, Type1 and Encoding Support
        • Page Compression
      • Notes

        • Performance: Fast
        • Cost: Free
        • Ease of use: Difficult
          • It is hard to use unless you play a lot with it.
          • Good documentation.
        • Other:
          • ( HTML- FPDF, PDF )
  • MPDF
    • , PDF HTML CSS PDF.
      • :
        • PDF HTML- UTF-8
        • FPDF HTML2FPDF
        • : Mediocre
          • ,
        • : Free
        • : Easy
          • - , HTML CSS MPDF)
          • .
        • CSS , CSS ,
  • PrinceXML
    • , , , .
      • :
          • ,
          • , , ,
          • ,
        • -
          • HTML, XHTML, XML, SVG
          • (CSS)
          • JavaScript/ECMAScript
          • JPEG, PNG, GIF, TIFF
        • PDF
          • , ,
          • PDF
          • PHP Ruby on Rails
          • Java
          • .NET # ASP
          • ActiveX/COM VB6
          • OpenType, TrueType CFF
          • , ,
          • , , , , , .
          • -,
        • : Fast
        • : $$$
            • 1 - $3,800
            • 2 - $3,420
            • 3 - $3,040
            • 4 - $2,850
            • 5+ - $2,800
          • OEM ( 2 , , , )
            • 20 000 5000 .
            • 100 000 7 500 .
            • 500 000 10 000
          • 50% $1900 Desktop $495, (. )
        • : Easy
        • PrinceXML (), .
  • DocRaptor

    • , API . PDF XLS. PrinceXML .

      • :

        • HTML, JS CSS
        • ,
        • Pretty much , PrinceXML, - , .
        • API-: PHP, NodeJS, Ruby, Python, Java, #
        • : Fast
          • -, , , , .
        • : $ - $$$
          • ( -):
            • - 125 / - $15/
            • - 325 / - $29/
            • - 1 250 / - $75/
            • - 5000 / - $149/
            • - 15 000 / - $399/.
            • - 40 000 / - 1000 /.
            • - 100 000 / - $2,250/
            • - ∞ docs/mo - ( )
        • : Very easy
          • , , .. PDF .
        • ​​, .
        • JavaScript, JavaScript
  • wkhtmltopdf
    • , (PrinceXML DocRaptor).
      • :
        • [] Qt WebKit
        • HTML-, PDF ( ). HTML- .
        • : Fast
        • : Free
        • : Easy
        • , HTML- CSS.
        • PDF, , $_SESSION, . $_GET.
  • :

. PDF - , ( ), -.

- HTML (, ). -, ( ), , . , .

, , - - (), , - ( PDF -, PDF - wkhtmltopdf).

, . HTML- PDF . ( ) , -, ( ). , , PDF ( , , , - , - , 2017 , ...). - PDF ( , , PDF ).

, !

+20

. API Aspose.PDF HTML PDF. SDK .

PHP HTML PDF:

//Html file with resource files
$name = "HtmlWithImage.zip";
$html_file_name = "HtmlWithImage.html";
$height = 650;
$width = 250;
$src_path = $name;
$response = pdfApi->getHtmlInStorageToPdf($src_path, $html_file_name, $height, $width);
print_r($response);
echo "Completed!!!!";

Aspose .

0

Source: https://habr.com/ru/post/1682679/


All Articles