How to create PDF from HTML file together with PHP?

   When you need to create PDF from any printable files like MS Word, PowerPoint, Excel, RTF, TXT, image, HTML, etc by some COM version software, software VeryDOC Doc Converter COM is a good choice. This software was developed for developers with some DLL Library, or Command Line, which enables you to call it together with Visual Basic, C/C++, Delphi, ASP, PHP, C#, .NET, etc. Please check more information on homepage, in the following part, let us check how to use this software.

Step 1. Download Doc Converter COM

When you use this software, please make sure you have the following software installed in your computer or else the conversion may fail.

  • PDFcamp V1.8 or newer, or PDFcamp Pro V1.8 or newer
  • Microsoft Windows 2000, XP, 2003, Vista, and 7
  • Windows Internet Explorer 5.0 or newer
  • Microsoft Office 97 or newer(when converting Office file to PDF)

When downloading finishes, it is a zip file. Please extract it to some folder then you can call it together with other applications.

Step 2. Create PDF from any printable files.

  • When you use this software, please refer to the usage and templates of this software.
  • Here I will share some code of creating PDF from online website together with PHP application.

How do I call DocConverter COM from PHP code?
A: Some examples for call DocConverter COM Service from PHP code:
Example 1:
                <?php
                        $url = "http://www.verypdf.com";
                        $path = "C:\\test.pdf";
                        $com = new COM("PdfOut.PdfCreator");
                        $com->html2PDF = $url;
                        $com->fileName = $path;
                        $com->Doc2PDFViaSocket();
                ?>
Example 2:
                <?php
                        $PdfCreator =new COM("PdfOut.PdfCreator") or die("Cannot start PdfCreator");
                        $PdfCreator->Doc2PDFCommandLine(' "c:\input.doc" "c:\output.pdf" ');
                        $PdfCreator = null;
                ?>
Example 3:
                <?php
                        $url = "http://www.verypdf.com";
                        $path = "C:\\test.pdf";
                        $com = new COM("PdfOut.PdfCreator");
                        $com->Doc2PDFCommandLine("\"$url\" \"$path\" \"paperType=0,PrintHTMLBackground=yes,overwrite=yes\"");
                ?>

By this software, you can also fulfill the following functions:

  • When creating PDF from HTML file, you can set input document filename or a URL point to a website. You also can set input content from a buffer, this function only can work for a html stream,please notice, you can't use "html2PDF" and "htmlBuffer" in one time.
  • Set page header in the PDF file, it only available when "headersFooters" equal "on".
  • Set page footer in the PDF file, it only available when "headersFooters" equal "on".
  • When creating PDF, you can also specify the page type like the followings:
  • Set page type, the value is from 0 to 9,
        0 "Letter [8.5 x 11 in]",
        1 "Legal [8.5 x 14 in]",
        2 "Executive [7.25 x 10.5 in]",
        3 "Ledger [355.6 x 215.9 mm]",
        4 "Tabloid [11 x 17 in]",
        5 "Screen [10 x 7.5 in]",
        6 "A3 [297 x 420 mm]",
        7 "A4 [210 x 297 mm]",
        8 "A5 [148 x 210 mm]",
        9 Custom page size

There are two many functions and examples of this software, I can not list all of here. During the using, if you have any question, please contact us as soon as possible.

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!