Is there a better way to convert files into PDF files using PHP?

Question:What is on VeryDOC the best way to convert uploaded files of any kind (.doc, .docx,...) into a PDF-file using nothing but PHP. Is it even possible to do so?I looked at FPDF, but this creates the PDF files from text.An other solution previously given was to use the some library on your server, but unfortunately, my server doesn't support this library...What is the best way to convert to files my users upload on my site to PDF files?

Answer: According to your needs, maybe you can have a free trial of this software: VeryDOC Doc Converter COM,by which you can convert files of Microsoft Word, PowerPoint, Excel, JPG, PNG, GIF, and HTML to PDF. And this COM is available via an easily integrated COM object (or DLL Library, or Command Line), enabling developers to access the converter via any programming or scripting languages, such as Visual Basic, C/C++, Delphi, ASP, PHP, C#, .NET, etc.  This COM is quite popular for developer to install it on sever for file formats conversion, so I guess there should have any problem to make it work on your server. Please know more detail information on its homepage, in the following part, let us check how to use this software.

Step 1. Free download Doc Converter COM

  • This is COM version, when downloading finishes, there will be a zip file. Please extract it to some folder then you can check related element and help documents.
  • When you open it then you will find code template of PHP, simply follow it then you can use this software easily at once.

Step 2. Convert Files to PDF using PHP

  • When you need to create PDF from files using PHP, please refer to the following code templates:

Some examples for call DocConverter COM Service from PHP code:
By this code template, we can create PDF from file URL, which means you can also convert website to PDF.

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();
?>
By this code template, we can convert local file to PDF.
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\"");
?>

During the using, if you have any question, please contact us as soon as possible.

VN:F [1.9.20_1166]
Rating: 4.5/10 (11 votes cast)
VN:F [1.9.20_1166]
Rating: -6 (from 8 votes)
Is there a better way to convert files into PDF files using PHP?, 4.5 out of 10 based on 11 ratings

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!