easyPDF SDK Usermanual
PDF Creator Programming API  |  Download Free Trial  |  Contact Us to Purchase

PrintOut2 Method

Prints a document into a PDF file. The output PDF is stored in memory.

Function PrintOut2(InFileName As String) As Variant

byte[] PrintOut2(string InFileName)

byte[] PrintOut2(String InFileName) throws PrinterException


Return Values

PDF file in byte array in (VT_ARRAY | VT_UI1) format.


An Error is raised if conversion is not successful.  You can obtain detailed information once you catch the error.

Note: If you are printing an HTML file located on local drive (i.e., "C:\test\input.htm"), then all links that points to external objects (such as images, style sheets) must be specified with absolute path (or using BASE tag), or the document will not be printed correctly.

Example Usage

    On Error goto Function_Err

    Set oPrinter = CreateObject("easyPDF.Printer.8")
    Set oPrintJob = oPrinter.PrintJob

    ' Convert to PDF
    arrPDF = oPrintJob.PrintOut2("C:\test\input.doc")

    ' Save binary data To disk using ADO stream object
    Set oADO = CreateObject("ADODB.Stream")
    oADO.Type = 1 ' 1: adTypeBinary
    oADO.Write arrPDF
    Call oADO.SaveToFile("C:\test\output.pdf", 2) ' 2: adSaveCreateOverwrite

    MsgBox "Success!"

    Exit Function

    ' Get error message
    MsgBox Err.Description

    ' Look at the error number
    If Err.Number = PRN_R_CONVERSION_FAILED Then
        ' More detailed error message
        MsgBox "Conversion Result: " + oPrintJob.ConversionResultMessage

        ' See if we have error message from printer driver
        nResult = oPrintJob.ConversionResult
        If nResult = PRN_CR_CONVERSION Or _
           nResult = PRN_CR_CONVERSION_INIT Or _
           nResult = PRN_CR_CONVERSION_PRINT Then
            ' Error message from printer driver
            MsgBox "Printer Result: " + oPrintJob.PrinterResultMessage

            ' You can also get the result in integer form
            nPrinterResult = oPrintJob.PrinterResult
        End If
    End If

    Resume Function_End