Home > Products > Document Printer

Document Printer (docPrint) SDK User Manual

1. Functions in docPrint SDK

int WINAPI docPrint_DocumentConverter(const char *lpDocFile, const char *lpOutputFile
const char *lpOptions)
WINAPI docPrint_DocumentConverterEx(const char * username, const char *password, const char *lpDocFile,const char *lpOutputFile, const char *lpOptions)

    These functions can be used to convert DOC, RTF, PPT, XLS, HTML, PDF, PS, Web URL etc. files to PDF, PS, EPS, TIFF, BMP, JPEG, PCX, etc. formats.
docPrint_DocumentConverterEx() will run the conversion from a special user account, this function is useful when you convert documents from ASP, PHP, C#, etc. server side applications.

Return value

       0 is success, otherwise indicate an error.

       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.

int nRet = docPrint_DocumentConverter("C:\input.doc", "C:\out.emf", "-e");
     int nRet = docPrint_DocumentConverter("C:\input.doc", "C:\out.pdf", NULL);
     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
       'Copyright (C) 2005-2008 by VeryPDF.com Inc
       'Web: /artprint/index.html
       'Convert *.DOC;*.RTF;*.PPT;*.XLS;*.VSD;*.PDF;*.HTML etc. files to PDF,PS,EPS,JPEG,TIFF,PNG,BMP,WMF,EMF etc. files
       'Please Notice: Command Line options are CASE SENSITIVE.
       'Release Date: Sep 9 2007
       '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
       '    -p 0          : overwrite if PDF file exists
       '    -p 1          : insert before first page if PDF file exists
       '    -p 2          : append to last page if PDF file exists
       '    -p 3          : rename filename if PDF file exists
       '-b <color type>   : specify color type for output file
       '    -b 1          : output black and white image file
       '    -b 8          : output 256 colors image file
       '    -b 24         : output True Colors image file
       '-c <compression>  : compression for TIFF output format
       '    -c 1          : NONE compression
       '    -c 2          : CCITT modified Huffman RLE
       '    -c 3          : CCITT Group 3 fax encoding
       '    -c 4          : CCITT Group 4 fax encoding
       '    -c 5          : LZW compression
       '    -c 6          : OJPEG compression
       '    -c 7          : JPEG DCT compression
       '    -c 32773      : PACKBITS compression
       '    -c 32809      : THUNDERSCAN compression
       '    -c 88880      : 204x98 G4 ClassF TIFF
       '    -c 88881      : 204x196 G4 ClassF TIFF
       '    -c 88882      : 204x98 G3 ClassF TIFF
       '    -c 88883      : 204x196 G3 ClassF TIFF
       '-R <Rotate>       : rotate page 90, 180, 270 angle
       '-r <resolution>   : set resolution in generated image file
       '    -r 300        : set X and Y resolution within document to image conversion
       '    -r 300x600    : set X and Y resolution within document to image conversion
       '    -r 200x300    : set X and Y resolution within document to image conversion
       '-w <image width>  : fix the paper width within document to image conversion
       '-h <image height> : fix the paper height within document to image conversion
       '-f <paper size>   : set the paper size to printer
       '    paper size can be selected either standard papers or user defined papers,
       '    look at following page for the standard papers:
       '    /artprint/document-converter/index.htm
       '    -f 8          : standard paper size
       '    -f "11x17in"  : set 11x17inch to printer
       '    -f "215.9x279.4mm" : set 215.9x279.4mm to printer
       '    -f "612x792pt" : set 612x792pt to printer
       '-z <PrintZoomPaper>: set print zoom paper for MS Office document printing
       '    -z 12240x15840 : scale to Letter print paper size
       '    -z 11907x16839 : scale to A4 print paper size
       '-e : set "docPrint" as default printer, otherwise, "docPrint PDF Driver" is the default printer
       '-E <types>        : options to process Excel Sheets
       '    -E 0          : print all Excel sheets one by one, and merge them together
       '    -E 1          : print all Excel sheets one by one, do not merge them together
       '    -E 2          : print all sheets with one print command from MS Excel
       '    -E 3          : create a PDF file for each sheet and a PDF for all sheets
       '-l <millisecond>  : wait a few milliseconds before convert HTML file
       '-V                : view the generated PDF file automatically
       '-d                : hide MS Office printing dialog within conversion
       '-y                : create 8-bit grayscale image file
       '-D                : improve speed for MS Office document conversion
       '-O <orientation>  : set orientation to printer
       '    -O 1          : PORTRAIT mode, default
       '    -O 2          : LANDSCAPE mode
       '-? : Help
       'doc2pdf -i C:\input.doc -o C:\output.pdf
       'doc2pdf -i C:\input.doc -o C:\output.emf
       'doc2pdf -i C:\input.doc -o C:\output.wmf
       'doc2pdf -i C:\input.doc -o C:\output.bmp
       'doc2pdf -i C:\input.xls -o C:\output.pdf
       'doc2pdf -i C:\input.vsd -o C:\output.tif
       'doc2pdf -i C:\input.pdf -o C:\output.tif
       'doc2pdf -i C:\input.ps -o C:\output.jpg
       'doc2pdf -i C:\input.eps -o C:\output.jpg
       'doc2pdf -R 90 -i C:\input.ppt -o C:\output.tif
       'doc2pdf -R 270 -i C:\input.ppt -o C:\output.tif
       'doc2pdf -i http://www.verypdf.com -o C:\output.pdf
       'doc2pdf -i C:\input.pdf -o C:\out.tif -b 24
       'doc2pdf -i C:\in.pdf -o C:\out.tif -b 1 -r 200x300
       'doc2pdf -i C:\in.pdf -o C:\out.jpg -b 24 -r 200x300
       'doc2pdf -i C:\*.doc -o C:\*.pdf
       'doc2pdf -i C:\*.xls -o C:\*.pdf
       'doc2pdf -i C:\*.xls -o C:\*.jpg
       'doc2pdf -p 2 -i C:\input.ppt -o C:\output.pdf
       'doc2pdf -a "Author" -i C:\input.dwg -o C:\output.pdf
       'doc2pdf -l 10000 -i http://www.verypdf.com -o C:\output.pdf

        strOptions = strOptions + "-b 1" 'Create 1 bit image file
        strOptions = strOptions + " -r 300x300" 'Set 300 DPI for conversion

        'Convert XLS to a multipage TIFF file
        iret = docPrint_DocumentConverter("C:\test_excel.xls", "C:\test1_excel.tif", strOptions)

        'Convert XLS to some single page TIFF files, one TIFF file per page
        iret = docPrint_DocumentConverter("C:\test_excel.xls", "C:\test2_excel-%03d.tif", strOptions)

        'Convert DOC to a multiple page TIFF file, black and white, 300x300DPI
        iret = docPrint_DocumentConverter("C:\test_word.doc", "C:\test1_word.tif", "-b 1 -r 300x300")

        'Convert DOC to some single page TIFF files, one TIFF file per page, black and white, 300x300DPI
        iret = docPrint_DocumentConverter("C:\test_word.doc", "C:\test2_word-%03d.tif", "-b 1 -r 300x300")

        'Convert DOC to a multile page PDF & Postscript file
        iret = docPrint_DocumentConverter("C:\test_word.doc", "C:\test_word.pdf", "")
        iret = docPrint_DocumentConverter("C:\test_word.doc", "C:\test_word.ps", "")

        'Convert DOC to EMF & WMF files, one EMF & WMF file per page
        iret = docPrint_DocumentConverter("C:\test_word.doc", "C:\test_word.emf", "-e")
        iret = docPrint_DocumentConverter("C:\test_word.doc", "C:\test_word.wmf", "-e")

        'Convert PDF, PS to JPEG, PNG, etc. files,
        iret = docPrint_DocumentConverter("C:\test.pdf", "C:\test.tif", "-b 1")
        iret = docPrint_DocumentConverter("C:\test.ps", "C:\test.jpg", "-b 24")
        iret = docPrint_DocumentConverter("C:\test.ps", "C:\test.png", "-b 24")
        iret = docPrint_DocumentConverter("C:\test.ps", "C:\test.bmp", "-b 24")

        MsgBox "Conversion Finished"
        ShellExecute 0, "open", "C:\test_word.pdf", vbNullString, vbNullString, SW_SHOWNORMAL
     End Sub

BOOL WINAPI docPrint_SetOptions(const char *lpKeyName, const char *lpString)

    docPrint_SetOptions() will write options into "config.ini" file, this function is useful if you wish print a document or drawing to docPrint Printer directly, docPrint_SetOptions() doesn't affect to the docPrint_DocumentConverter() and docPrint_DocumentConverterEx() functions,

docPrint_SetOptions() function supports following options,





1 or 0

Indicate create a multi-page image format or not, Choices are: 1, 0;


1, 8, 16, 24

Specify color depth for the created image format, Choices are: 1, 8, 24;


200, 200x200, 100x200, 600x600, etc.

Specify resolution for the created the image format;


1 or 0

Indicate create a grayscale image format or not, Choices are: 1, 0;


-compress Group4

-quality 100

Set compression method and quality level for TIFF format;


-quality 100

Set quality level for JPEG format


1 or 0

1 - indicate the “strWidthAndHeight” parameter available;
0 - indicate the “m_strResolution” parameter available;


600, 600x0, 1200x0, 0x800, 600x800, etc.

600 – Width and Height are 600 pixel;
600x0 – Width is 600 pixel, height is auto;
1200x0 - Width is 1200 pixel, height is auto;
0x800 - Width is auto, height is 800 pixel,
600x800 – Width is 600 and height is 800.


%d, %04d, __%06d, etc.

Specify filename suffix for the multiple image files, it is available when m_bCreateFileForEachPage = 1;

*Description for the "-compress" option,
     Choices are: None, BZip, Fax, Group4, JPEG, Lossless, LZW, RLE or Zip.
     "Lossless" refers to lossless JPEG, which is only available if the JPEG library has been patched to support it. Use of lossless JPEG is generally not recommended.
     Use the -quality option to set the compression level to be used by JPEG, PNG encoders.



       Private Sub GDIFuncs_Click()
           Dim mytest As String
           Dim width As Long
           Dim height As Long


           mytest = "This is a test!"
           width = Printer.TextWidth(mytest) / 2
           height = Printer.TextHeight(mytest) / 2
           Printer.CurrentX = Printer.ScaleWidth / 2 - width
           Printer.CurrentY = Printer.ScaleHeight / 2 - height
           Printer.Print mytest
           Printer.Circle (200, 200), 1200, RGB(255, 0, 0)
       End Sub

BOOL WINAPI docPrint_ChangePrinterSettings(const char *ptrPrintName,DEVMODE *lpDevMode)

This function can be used to change the default options in the docPrint Printer, please see MSDN for more details,


       //Set the docPrint to 100x100 DPI
       DEVMODE nDevMode;
       nDevMode.dmPrintQuality = 100;
       nDevMode.dmYResolution = 100;

2. Some questions

2.1 How to check if "docPrint" has been installed?
A: After you installed docPrint application, you can use "OpenPrinter" function to check the "docPrint" whether exist, for example,
       HANDLE hPrinter;
       if (OpenPrinter("docPrint", &hPrinter, NULL))

              return TRUE;
       return FALSE;

3. How to convert documents from ASP, PHP, C#, etc. server side applications?

ASP Example:

After you installed docPrint Pro into your system, you can simple run following ASP code to convert your documents to other formats,
        'On Error Resume next
        Set docPrint = Server.CreateObject("DocPrintCom.docPrint")

        DocumentConverter docPrint, "VeryPDF.doc", "VeryPDF.pdf", ""
        DocumentConverter docPrint, "VeryPDF.doc", "VeryPDF.ps", ""
        DocumentConverter docPrint, "VeryPDF.doc", "VeryPDF.jpg", ""
        DocumentConverter docPrint, "VeryPDF.doc", "VeryPDF.png", ""
        DocumentConverter docPrint, "VeryPDF.doc", "VeryPDF.tif", " -b 1 -r 300"
        function DocumentConverter(byval docPrint, strInFile, strOutFile, strOptions)
            Dim strFullInFileName,strFullOutFileName
            Dim strRootPath
            Dim strAllOptions

            strRootPath = Server.MapPath(".") & "\"
            strFullInFileName = strRootPath & strInFile
            strFullOutFileName = strRootPath & strOutFile

            ' Please replace "XXXXXXXXXXXXXX" with your real License Key which issued by VeryPDF.com company
            ' Please notice, the trial version of docPrintCOM_DocumentConverterEx() will popup a message box,
            ' this message box will hang the ASP application, so docPrintCOM_DocumentConverterEx() function
            ' will not work from ASP code in the trial version of docPrint SDK product.
            ' However, you can test "doc2img.dll" instead of "docPrintCom.dll" in the trial version of docPrint SDK,
            ' you can call
"doc2img.dll" from VB, VC++, Delphi, etc. program languages easily for test purpose.

            strAllOptions = """-*"" ""XXXXXXXXXXXXXX"""
            strAllOptions = strAllOptions & strOptions
            nRet = docPrint.docPrintCOM_Register("XXXXXXXXXXXXXX", "VeryPDF.com Company")

            ' Execute document conversion from "
Administrator" user account,
            nRet = docPrint.docPrintCOM_DocumentConverterEx("Administrator", "123456", strFullInFileName, strFullOutFileName,  strAllOptions)

            strHTMLCode = strFullInFileName & " ==> " & strFullOutFileName & "<br>"
            strHTMLCode = strHTMLCode & "<A href=""" & strOutFile & """ target=""_blank"">" & strOutFile & "</A><br>"
            Response.write strHTMLCode
end function

C# Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestWithVeryPDF
    class Program
        static void Main(string[] args)
                DocPrintCom.docPrint docPrintObj = new DocPrintCom.docPrint();
                docPrintObj.docPrintCOM_Register("XXXXXXXXXXXXXX", "VeryPDF.com Company")
                docPrintObj.docPrintCOM_DocumentConverterEx("Administrator", "123456", "C:\test.doc", "C:\out.pdf", "-* XXXXXXXXXXXX -d")
                docPrintObj = null;
            catch (Exception e)

PHP Example:

    $com = new COM("
    $com->docPrintCOM_Register("XXXXXXXXXXXXXX", "VeryPDF.com Company")
$com->docPrintCOM_DocumentConverterEx("Administrator", "123456", "C:\test.doc", "C:\out.pdf", "-* XXXXXXXXXXXX -d")