locked
Error Printing Cheques from VB.NET Windows Application, does not print Signature RRS feed

  • Question

  • We are migrating an application from Visual Basic 6.0 to VB.NET 3.5 (Windows). One of the feature of the application is to print cheque with a signature in a special font. It Prints fine in the Visual Basic 6.0 application but is missing in migrated VB.NET application The same is explained below.

    In VB Application below command is used for printing cheque number/signature.

    result% = ExtEscape(Printer.hdc, 19, Len(PCL_Escape$), PCL_Escape$, lout, sout)

    where PCL_Escape is string variable that contains cheque number/signature string.

    In .NET Printer.hdc property of printer is obsolete. So we have created graphics object and used its getHDC method

    Dim graphicObj As Graphics = Me.CreateGraphics()
    Dim iHDC As IntPtr
    iHDC = graphicObj.GetHdc()

    result = ExtEscape(iHDC.ToInt32(), 19, Len(PCL_Escape), PCL_Escape, lout, sout)
    where PCL_Escape is string variable that contains cheque number/signature string.

    Problem: Signature is not printing in the VB.NET application. Please recommend a solution. Is there other way to get HDC, or any other way to resolve this issue... Thanks!


    • Edited by qaizar Tuesday, November 20, 2012 5:15 PM
    • Moved by Mike FengModerator Friday, November 23, 2012 2:10 PM (From:.NET Base Class Library)
    Tuesday, November 20, 2012 4:04 PM

Answers

  • Whats the proper way to get hdc using .NET printing classes. Please advice.

    You don't need the hdc to print using PrintDocument or the PowerPacks Printer.  If you insist on using your legacy code, you'll have to get the printer.hdc using the WinAPI.
    Tuesday, November 20, 2012 10:27 PM

All replies

  • Print it using either the PrintDocument component or the  PowerPacks printer.
    Tuesday, November 20, 2012 6:49 PM
  • I need to get the hdc. Can you please send me sample code to get HDC using PrinterDocument. Thanks!

    Tuesday, November 20, 2012 9:51 PM
  • I need to get the hdc. Can you please send me sample code to get HDC using PrinterDocument. Thanks!

    If you don't want to use .NET printing classes, you'll have to use the WinAPI.
    Tuesday, November 20, 2012 10:08 PM
  • Whats the proper way to get hdc using .NET printing classes. Please advice.

    Tuesday, November 20, 2012 10:12 PM
  • Whats the proper way to get hdc using .NET printing classes. Please advice.

    You don't need the hdc to print using PrintDocument or the PowerPacks Printer.  If you insist on using your legacy code, you'll have to get the printer.hdc using the WinAPI.
    Tuesday, November 20, 2012 10:27 PM