How convert txt or doc to PDF using php?

Question:Have anyone come across an application which can 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, hoping there is a proper solution on VeryPDF? Let say I have a list of txt files and they could be inside a subdirectories example folder1/abc.txt ,folder1/pqr.txt , folder1/folder2/def.txt etc.... I am looking to write a code that automatically read those txt files and convert it into PDF.but they got to have the same paragraphing as the original txt file.

Answer: According to your description, you need to convert doc, text to PDF and keep original format and layout after conversion. If so, maybe you can have a free trial of software VeryPDF Document Printer SDK, which is a good application for converting all the printable files to PDF. And by the SDK version software, you can use this software together any applications like #, VB .NET, MS Visual Basic, Borland Delphi, VBA (MS Office products such as Access) and C++ via COM, C and C++ via native C.  Please check more information on homepage, in the following part, let us check how to use this software.

Step 1. Free download Document Printer SDK

  • All the VeryPDF software are free downloading including all the SDK version. So you can rest assured to evalute it and then decide to pay for it or not.
  • When downloading finishes, there will be an zip file. Please extract it to some folder then you can find related elements.

Step 2. Convert doc to PDF using php code.

  • When you use this software, you may use the following parameters and reminding information.
  • Return value
           0 is success, otherwise indicate an error.
    Parameters
           username: string that specifies the user name.
        password: string that specifies the password.

           lpDocFile: specify the document file name for convert; it can be .doc, .rtf, .ppt, .xls, etc documents.
    lpOutputFile: specify the image format for output, it can be .tif, .jpg, .wmf, .emf, etc. formats.
           lpOptions: additional options for Document Conversion.

    Example
        int nRet = docPrint_DocumentConverter("C:\test_word.doc", "C:\test_word.pdf", "")
       int nRet = docPrint_DocumentConverter("C:\test_word.doc", "C:\test_word.ps", "")
       int nRet = docPrint_DocumentConverter("C:\test_word.doc", "C:\test_word.eps", "")
       Private Declare Sub docPrint_Register Lib "doc2img.dll" (ByVal lpOrderID As String, ByVal lpCompanyName As String)
       Private Declare Function docPrint_SetOptions Lib "doc2img.dll" (ByVal lpKeyName As String, ByVal lpString As String) As Long
       Private Declare Function docPrint_DocumentConverter Lib "doc2img.dll" (ByVal lpDocFile As String, ByVal lpOutputFile As String, ByVal lpOptions As String) As Long
       Private Declare Function docPrint_DocumentConverterEx Lib "doc2img.dll" (ByVal lpUserName As String, ByVal lpPassword As String, ByVal lpDocFile As String, ByVal lpOutputFile As String, ByVal lpOptions As String) As Long
    Private Sub DocumentConverterDLL_Click()
            Dim iret As Long
            Dim strOptions As String
            docPrint_Register "XXXXXXXXXX", "XXXX Corporation"
           'Please run following command line to get more options for doc2pdf converter
           'C:\>"C:\Program Files\docPrint Pro v4.0\doc2pdf.exe" -?
           'docPrint Document Converter Professional v3.3
          -------------------------------------------------------
            'Usage: doc2pdf [options] <-i Document Files> [-o Output]
           '-i <input files>  : filename for input
           '-o <output files> : filename for output
           '-j <subject>      : "subject" for PDF file
           '-t <title>        : "title" for PDF file
           '-a <author>       : "author" for PDF file
           '-k <keywords>     : "keywords" for PDF file
           '-g <page range>   : page range for conversion, eg: 1,2-4,6
           '-G                : don't append suffix to filename for single page file
           '-p <output Flag>  : a flag for PDF output

There are too many parameters and functions of this software, I can not list all of them here. Please check more on user Manual. During the using, if you have any question, please contact us as soon as possible.

VN:F [1.9.20_1166]
Rating: 7.4/10 (21 votes cast)
VN:F [1.9.20_1166]
Rating: -2 (from 2 votes)
How convert txt or doc to PDF using php?, 7.4 out of 10 based on 21 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!