Home > Products > PDFcamp Printer

User Manual of Doc Converter COM Component

1. Step by Step to install the DocConverter COM product

    1.1. Please download and install PDFcamp Printer v2.3 or PDFcamp Printer Pro v2.3 from our website,
    /pdfcamp/pdfcamp_setup.exe

    1.2. Please download DocConverter COM from our website,
    /pdfcamp/doc2pdf_com_trial.zip

    1.3. Please unzip "doc2pdf_com_trial.zip" package to a folder, and run "install_as_exe.bat" file to install the DocConverter COM into your system,

    1.4. Then you can run HTML2PDF.exe from command line to try, HTML2PDF.exe is a Windows Command Line Tool, you can run it from command line window,
        For example:
        html2pdf.exe "http://www.yahoo.com" "C:\yahoo.pdf"
        html2pdf.exe "http://www.google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=pdf" "C:\google.pdf"
        html2pdf.exe "C:\example.doc" "C:\example.pdf"
        html2pdf.exe "C:\example.xls" "C:\example.pdf"

        A screen shot of HTML2PDF.exe application,
   

    1.5. You can run "doc2pdf_html" or "doc2pdf_vb" or "doc2pdf_exe" projects to test its capability from HTML file and VB project.

2. Description for files and directories in DocConverter COM package

pdfout.dll:

    This is the DocConverter COM Component, you must register it into your system prior to use the HTML2PDF.exe application, "install_as_exe.bat" and "install_as_service.bat" files will install and register pdfout.dll file into your system automatically.

install_as_service.bat:
    It will copy all necessary files to system32 folder and install "doc2pdf_service.exe" as a System Service, the Service Name is "VeryPDF DocConverter COM Service", you can start, stop, restart this Service from Windows System Service Management Application.

install_as_exe.bat:
    It will copy all necessary files to system32 folder and install "doc2pdf_service.exe" as a Normal Windows Application.

uninstall.bat:
    It will uninstall DocConverter COM from your Windows System.

doc2pdf_service.exe:
    This is a Windows Service Application, it is useful for PHP, ASP, C#, VB.NET, ASP.NET, etc. Web Service Applications, for example, once you call DocConverter COM from PHP, ASP, C#, VB.NET, ASP.NET applications, doc2pdf_service.exe will accept and execute all conversion tasks automatically. This application will be started by "install_as_exe.bat" and "install_as_service.bat" files.

Examples for doc2pdf_service.exe software:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"doc2pdf_service.exe" can be started at two methods, run as a Windows System Service and run as a Normal Windows Application,
1. Run As a Normal Windows Application

C:\>doc2pdf_service.exe "-exe"
This Command Line will run doc2pdf_service.exe as a normal windows application.

2. Run As a Windows Service

C:\>doc2pdf_service.exe -i
This Command Line will install the "VeryPDF DocConverter COM Service" into your system.

C:\>doc2pdf_service.exe -u
This Command Line will uninstall the "VeryPDF DocConverter COM Service" from your system.

C:\>net start "VeryPDF DocConverter COM Service"
C:\>net stop "VeryPDF DocConverter COM Service"
Above Command Lines will start/stop "VeryPDF DocConverter COM Service" from your system.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

readme.txt:

    This file.

doc2pdf_html:

    A html file will let you know how to call DocConverter COM from your html page.

doc2pdf_asp:
    An example will let you know how to use DocConverter COM from ASP program.

doc2pdf_vb:

    A VB project will let you know how to call DocConverter COM from your VB program.

doc2pdf_exe:
    The VB source code of the HTML2PDF.exe application. (The HTML2PDF.exe's source code is only available in the full version of DocConverter COM package, the trial version hasn't this folder.)

html2pdf.exe:

    This is a VB Command Line utility tool, you can convert any printable documents to PDF files with this tool, such as MS Office documents (DOC, DOCX, PPT, PPTX, XLS, XLSX, RTF, TXT, etc.) to PDF files conversion, it also supports dynamic HTML pages and URLs to PDF files conversion (include Java Applet, SVG, Flash, Javascript, iFrame, etc.). It supports command line operation, you can use it by following command lines,

    For example:
    html2pdf.exe "http://www.yahoo.com" "C:\yahoo.pdf"
    html2pdf.exe "http://www.google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=pdf" "C:\google.pdf"
    html2pdf.exe "C:\example.doc" "C:\example.pdf"
    html2pdf.exe "C:\example.xls" "C:\example.pdf"

More Examples for HTML2PDF.exe software:

Use Letter paper in portrait mode,
html2pdf.exe "http://www.google.com" "C:\google.pdf" "papertype=0"

Use Letter paper in landscape mode,
html2pdf.exe "http://www.google.com" "C:\google.pdf" "paperType=9,pageWidth=792,pageHeight=612"

Use A4 paper in portrait mode,
html2pdf.exe "http://www.google.com" "C:\google.pdf" "papertype=7"

Use A4 paper in landscape mode,
html2pdf.exe "http://www.google.com" "C:\google.pdf" "paperType=9,pageWidth=842,pageHeight=595"

Use A3 paper in portrait mode,
html2pdf.exe "http://www.google.com" "C:\google.pdf" "papertype=6"

Use A3 paper in landscape mode,
html2pdf.exe "http://www.google.com" "C:\google.pdf" "paperType=9,pageWidth=1190,pageHeight=842"

Use A1 paper,
html2pdf.exe "http://www.google.com" "C:\google.pdf" "paperType=9,pageWidth=1684,pageHeight=2384"

Use A2 paper,
html2pdf.exe "http://www.google.com" "C:\google.pdf" "paperType=9,pageWidth=1191,pageHeight=1684"

Use A3 paper,
html2pdf.exe "http://www.google.com" "C:\google.pdf" "paperType=9,pageWidth=842,pageHeight=1191"

Use A4 paper,
html2pdf.exe "http://www.google.com" "C:\google.pdf" "paperType=9,pageWidth=595,pageHeight=842"

You can select more paper types for "papertype" value,
~~~~~~~~~~~~~~~~~
        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]",
~~~~~~~~~~~~~~~~~

Set page header&footer for HTML to PDF conversion,
"html2pdf.exe" "www.yahoo.com" "C:\yahoo.pdf" "htmlHeaders=this is header,htmlFooters=this is footer"

Set values for page header&footer within HTML to PDF conversion,
"html2pdf.exe" "www.yahoo.com" "C:\yahoo.pdf" "htmlHeaders=&w&bPage &p/&P,htmlFooters=&u&b&d"

Set passwords for DOC, DOCX, HTML, MHTML, PPT, PPTX, XLS, XLSX, RTF, etc. document to PDF conversion,
"html2pdf.exe" "C:/Doc1.DOC" "C:/Doc1.pdf" "Encryption=2,EncryBits=16,Permission=0,UserPass=,OwnerPass=123"

Set page margin within conversion,
"html2pdf.exe" "http://www.yahoo.com" "C:/yahoo.pdf" "paperType=9, pageWidth=575, pageHeight=850, margin_left=10, margin_top=40, margin_right=10, margin_bottom=40"

Set username&password for encrypted site to PDF conversion,
html2pdf "http://www.xxxxxx.com/index.html" "C:/output.pdf" "postdata=Username=support@verypdf.com&Password=password"

Append "C:/test.txt" file to the end of "C:/output.pdf" file,
"html2pdf.exe" "C:/test.txt" "C:/output.pdf" "AutomaticValue=4,Overwrite=yes"
"html2pdf.exe" "C:/test.doc" "C:/output.pdf" "AutomaticValue=4,Overwrite=yes"
"html2pdf.exe" "C:/test.html" "C:/output.pdf" "AutomaticValue=4,Overwrite=yes"

Insert "C:/test.txt" file before the first page of "C:/output.pdf" file,
"html2pdf.exe" "C:/test.txt" "C:/output.pdf" "AutomaticValue=3,Overwrite=yes"
"html2pdf.exe" "C:/test.doc" "C:/output.pdf" "AutomaticValue=3,Overwrite=yes"
"html2pdf.exe" "C:/test.html" "C:/output.pdf" "AutomaticValue=3,Overwrite=yes"

Overwrite to an existing PDF file,
"html2pdf.exe" "C:/test.doc" "C:/output.pdf" "Overwrite=yes"

Convert a HTML file which contains Javascript or Java Applet or iFrame or SVG or Flash codes to PDF file,
(You need wait more than 10000 millisecond before convert such HTML files)
"html2pdf.exe" "C:/javascript_test.htm" "C:/output.pdf" "EnableSupportApplet=yes,DelayTimeForPrintApplet=10000"

Convert background color and images within html to PDF conversion,
"html2pdf.exe" "/pdfcamp/pdfcamp.htm" "C:/output.pdf" "PrintHTMLBackground=yes"
"html2pdf.exe" "/pdfcamp/pdfcamp.htm" "C:/output.pdf" "PrintHTMLBackground=no"

Show status bar within HTML to PDF conversion,
"html2pdf.exe" "/pdfcamp/pdfcamp.htm" "C:/output.pdf" "showStatusBar=on"

You also can call this program from any other programs or inclusion in scripts.
Please notice, you must use the quotation mark(") to include the input and output file name.

3. How to use DocConverter COM from my program?

3.1 How convert a DOC, DOCX, RTF, PPT, PPTX, XLS, XLSX, TXT etc. files to PDF files from my html page?
A: You may use notepad.exe software to open the doc2pdf_html\test.htm file, and find following function,

            function Word2PDF()
            {
                    //please modify the input and output file name at here
                    hh3.Word2PDF("C:/input.doc","C:/output.pdf");
            }

After you finished the modification, please save it and close your notepad software, then please run the test.htm file, click the "Word2PDF" button, then you'll convert "C:/input.doc" document to "C:/output.pdf" document.

3.2 How convert a html file to PDF file from my html page?
A: Please refer to the
doc2pdf_html\test.htm file, please use following function to convert a html file or URL to a PDF file,

            function CreatePDF()
            {
                    hh3.headersFooters = "off";
                    hh3.html2PDF= "http://www.yahoo.com/";
                    hh3.fileName = "C:/html2pdf.pdf";
                    hh3.CreatePDF();
            }
Online Examples for "
Call DocConverter COM from HTML page", Example1, Example2.

3.3 How convert html, doc, docx, rtf, xls, xlsx, ppt, pptx etc files to PDF files from my VB program?
A: Please refer to the "doc2pdf_vb" folder, this project contain some examples for doc, rtf, html, txt, etc. files to PDF files conversion.
   
You can use the "doc2pdf_vb" project to test this COM, you may open this project in VB6, and modify some input and output file names, then compile and run it to try.

3.4 How convert html, doc, docx, rtf, xls, xlsx, ppt, pptx, txt etc files to PDF files from other programs (C++, VC, Delphi, Power Build, Java, .NET, etc.)?
A: You can simple call the "html2pdf.exe" software from these programs directly.

3.5 How convert html, doc, docx, rtf, xls, xlsx, ppt, pptx, txt etc files to PDF files from my ASP program?
A: Please by following steps to try,
1. Please run "install_as_exe.bat" to install the DocConverter COM first, and make sure the "doc2pdf_service.exe" application is running,
2. Please make sure that you have already installed "PDFcamp Printer" before,
3. Please run following ASP examples to try,
                Example1:
                <%
                        set PdfCreator = server.createobject("PdfOut.PdfCreator")
                        PdfCreator.html2PDF= "http://www.google.com/"
                        PdfCreator.fileName = "C:/google.pdf"
                        result = PdfCreator.Doc2PDFViaSocket() 
                        set PdfCreator = nothing
                %>
                Example2:
                <%
                        set PdfCreator = Server.CreateObject("PdfOut.PdfCreator")
                        ConvertHTMLToPDF1 PdfCreator,"http://www.google.com","google001.pdf"
                        set PdfCreator = nothing

                        function ConvertHTMLToPDF1(byval PdfCreator, strHTMLFile, strPDFFile)
                                'The first method to create a PDF file from HTML file
                                strPDFFile = server.mappath(".") & "\" & strPDFFile
                                dim strCommandLine
                                strCommandLine = """" + strHTMLFile + """"
                                strCommandLine = strCommandLine + " "
                                strCommandLine = strCommandLine + """" + strPDFFile + """"
                                strCommandLine = strCommandLine + " "
                                strCommandLine = strCommandLine + """" + "paperType=6" + """"
                                Response.write "HTML To PDF Command Line1 is: " & strCommandLine & "<br>"
                                PdfCreator.Doc2PDFCommandLine(strCommandLine)
                        end function
                %>
4. Then you can convert .html, URL, .doc, .docx, .rtf, .ppt, .pptx, .xls, .xlsx, txt etc. files to PDF files from your ASP code.

3.6 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\"");
                ?>

3.7 How do I call DocConverter COM from VC++ code?
A: Please look at following VC++ function,
                BOOL ConvertHTMLToPDF (const char *lpHTMLFile, const char* lpPDFFile)
                {
                        IPdfCreator pdfout;
                        BOOL bRet = pdfout.CreateDispatch(_T("PdfOut.PdfCreator"));
                        if(bRet == FALSE)
                        {
                                printf("Can't locate 'PdfOut.PdfCreator' in this computer, please reinstall this product to try again.\n");
                                return FALSE;
                        }
                        pdfout.SetActivePrinter("PDFcamp Printer");
                        pdfout.SetFileName(lpPDFFile);
                        pdfout.SetHtml2PDF(lpHTMLFile);
                        pdfout.SetPaperType(0);
                        pdfout.CreatePDF();
                        while(pdfout.GetStillRunning() == 1)
                        {
                                MSG msg;
                                while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
                                {
                                        TranslateMessage (&msg);
                                        DispatchMessage (&msg);
                                }
                                Sleep(20);
                        }
                        pdfout.DetachDispatch();
                        return TRUE;
                }

For more information, please read the "readme.txt" file in the "doc2pdf_asp" folder.

4. Important issues for the DocConverter COM product

4.1 For ASP example:
      1 You need run "install_as_exe.bat" file first, and make sure "doc2pdf_service.exe" application is running,
      
2. Please make sure "html2pdf.exe", "doc2pdf_service.exe", "doc2pdf_config.ini" and "pdfout.dll" files have been installed into your system32 folder,
      3. Please make sure you have already installed "PDFcamp Printer" product.

4.2 For HTML to PDF Conversion:
      You need install the MS Internet Explorer 6.0 (MS IE6.0) to convert HTML files to PDF files, the MS IE5.0 and IE5.5 are not enough.

4.3 For MS Office documents to PDF Conversion:
      You need install MS Word, Excel, PowerPoint, etc. applications to convert corresponding documents to PDF files.

5. Four methods to convert MS Office documents (DOC, DOCX, RTF, PPT, PPTX, XLS, XLSX, TXT, HTML, URL, etc.) to PDF files

    5.1 Use MS Internet Explorer Control method
        ~~~~~~~~~~~~~~~~~~~
        Set PdfCreator = New PDFOUTLib.PdfCreator

        PdfCreator.HTML2PDF = "C:\sample.doc"
        PdfCreator.FileName = "C:\sample.doc.pdf"
        PdfCreator.HeadersFooters = "off"
        PdfCreator.paperType = 7 '//7 is A4 paper, 6 is A3 paper
        PdfCreator.CreatePDF
        While PdfCreator.StillRunning = 1
            DoEvents
            Call WaitMessage
        Wend
        Set PdfCreator = Nothing
        ~~~~~~~~~~~~~~~~~~~

    5.2 Use Shell Print method (Print from Windows Explorer)
        ~~~~~~~~~~~~~~~~~~~
        Set PdfCreator = New PDFOUTLib.PdfCreator

        PdfCreator.Word2PDF "C:\sample.doc", "C:\sample.doc.pdf"
        PdfCreator.Word2PDF "C:\sample.xls",  "C:\sample.xls.pdf"
        PdfCreator.Word2PDF "C:\sample.ppt", "C:\sample.ppt.pdf"
        MsgBox "Word2PDF_ShellPrint finished"
        Set PdfCreator = Nothing
        ~~~~~~~~~~~~~~~~~~~

    5.3 Use MS Office OLE method
       
Please refer to "doc2pdf_exe" folder for detailed usages, this folder contains VB source code for HTML2PDF.exe software, this source code is only available in the full version of DocConverter COM package.

    5.4 Use "HTML2PDF.exe" Command Line application
        You can call "html2pdf.exe" Command Line software from your application directly, this is an easiest method.

If you encounter any problems, please feel free to contact us at support@verypdf.com.

Contact:
    support@verypdf.com
    /