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

PrinterResult Property

Gets printer driver printing result in integer format.

Type

prnPrinterResult (read-only)

Remarks

If an error is not raised during PDF conversion, you do not need to check this property.

prnPrinterResult is used together with prnResult and prnConversionResult to determine the cause of an error, as if they were fused together as shown below:

If the exception's ErrorCode is PRN_R_CONVERSION_FAILED, then you should investigate ConversionResult to see why the conversion has failed. Otherwise you should ignore ConversionResult.

If ConversionResult is PRN_CR_CONVERSION, PRN_CR_CONVERSION_INIT, or PRN_CR_CONVERSION_PRINT, then you should check PrinterResult to see why printing has failed. Otherwise you should ignore PrinterResult.

In other words, treat prnResult, prnConversionResult and prnPrinterResult as if they were merged together into one huge enumeration. Only go to a deeper level when necessary.

Example Usage

On Error goto Function_Err

Set oPrinter = CreateObject("easyPDF.Printer.8")
Set oPrintJob = oPrinter.PrintJob
oPrintJob.PrintOut "C:\test\input.doc", "C:\test\output.pdf"

Function_End:
    Exit Function

Function_Err:
    ' 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

Example Usage (C#)

Printer printer = new Printer();
try
{
   printer.PrintJob.PrintOut(@"c:\test\input.docx", @"c:\test\output.pdf");
}
catch(System.Runtime.InteropServices.COMException err)
{
   // Get the error message
   MessageBox.Show(string.Format("Error: {0} ({1})", err.Message, err.ErrorCode));
   if(err.ErrorCode == (int)prnResult.PRN_R_CONVERSION_FAILED)
   {
      // More detailed error message
      MessageBox.Show(string.Format("Conversion Result: {0} ({1})", printer.PrintJob.ConversionResultMessage, printer.PrintJob.ConversionResult));

      // See if we have error message from printer driver
      switch(printer.PrintJob.ConversionResult)
      {
         case prnConversionResult.PRN_CR_CONVERSION:
         case prnConversionResult.PRN_CR_CONVERSION_INIT:
         case prnConversionResult.PRN_CR_CONVERSION_PRINT:
            // Error message from printer driver
            MessageBox.Show(string.Format("Printer Result: {0} ({1})", printer.PrintJob.PrinterResultMessage, printer.PrintJob.PrinterResult));
            break;
      }
   }
}