Question:Have anyone come across a PHP code that convert text or doc into PDF? It has to follow the same format as the original txt or doc file meaning the line feed as well as new paragraph.... I mean if the conversion could keep original format that would be much more better. Is there any solution on VeryDOC?
Answer: According to your needs, maybe you can have a free trial of software VeryDOC DOC to Any Converter,by which you can convert text and doc file to PDF using PHP easily. And by this software, you can convert all version word document files to PDF. And when converting doc to PDF, you do not need to install MS Office, which means the conversion from doc to PDF by this software is totally independent. Please check more related information of this software on homepage. In the following part, let us check how to use this software.
Step 1. Free download DOC to Any Converter SDK/COM Version
- There are many versions of this software like single command line version, GUI version and SDK version. Here I will take the SDK version for example as there are many code templates in it, by which you can call this software from PHP more easily.
- When downloading finishes, there will be a zip file. Please extract it to some folder then you can find code templates, executable file and other related elements.
Step 2. Convert text or doc to PDF using PHP without MS Office installed.
- When you use this software, please refer to parameter list and usage.
- When converting text or doc to PDF, you may use the following parameters:
- When converting text or doc to PDF using PHP code, please refer to the following code templates:
For text to PDF using PHP code:
-useoffice <int>: Use MS Office to render DOC, DOCX, RTF, TXT, PPT, PPTX, PPTS, PPTSX, XLS, XLSX formats
-useoffice 0: Don't use MS Office to convert DOC, DOCX, RTF, TXT, PPT, PPTX, XLS, XLSX formats
-useoffice 1: Use MS Office to convert DOC, DOCX, RTF, TXT, PPT, PPTX, XLS, XLSX formats
-useprinter : Convert DOC files to other formats via virtual printer
-width <int> : Set page width to PDF file
-height <int> : Set page height to PDF file
-openpwd <string> : Set 'open password' to PDF file
-ownerpwd <string> : Set 'owner password' to PDF file
<?php
$exeshell =new COM("exeshell.shell") or die("Can't start exeshell");
$exeshell->RunCommandLine("UserName", "Password", ' "C:\doc2any.exe" "C:\test.txt" "C:\out.pdf" ');
$exeshell = null;
?>
For doc to PDF using PHP code:
<?php
$exeshell =new COM("exeshell.shell") or die("Can't start exeshell");
$exeshell->RunCommandLine("UserName", "Password", ' "C:\doc2any.exe" "C:\test.doc" "C:\out.pdf" ');
$exeshell = null;
?>
Please check functions and parameters of this software on homepage. During the using, if you have any question, please contact us as soon as possible.