How to print image and Text using StarDoc, EndDoc

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phuongnguyen203
    New Member
    • Oct 2014
    • 1

    How to print image and Text using StarDoc, EndDoc

    I'm using StarDoc , EndDoc to print text rotation and image, but i print text only.

    Here my code:

    hPrintDc = CreateDC(Printe r.DriverName, Printer.DeviceN ame, 0, 0)

    result = StartDoc(hPrint Dc, di) 'Start a new print document
    result = StartPage(hPrin tDc) 'Start a new page
    ' hMemoryDC = CreateCompatibl eDC(GetDC(0))
    'mBitmap = CreateCompatibl eBitmap(hMemory DC, Me.Width / Screen.TwipsPer PixelX, Me.Height / Screen.TwipsPer PixelY)
    ' Select our rotated font structure and save previous font info
    hOldfont = SelectObject(hP rintDc, hFont)
    'Select the bitmap into the device context
    'result = SelectObject(hM emoryDC, mBitmap)

    ' Send rotated text to printer, starting at location 1000, 1000
    TextOut hPrintDc, 1000, 1000, OutString, Len(OutString)

    ' Reset font back to original, non-rotated
    SelectObject hPrintDc, hOldfont
    'SelectObject hMemoryDC, hOldBitMap
    Dim path As String
    path = "C:\cup.bmp "
    Picture1.Pictur e = LoadPicture(pat h)

    Printer.PaintPi cture Picture1.Image, rect.X, rect.Y, Picture1.Width, Picture1.Height
    'TextOut hPrintDc, 2000, 2000, Picture1.Image, Len(path)
    Printer.EndDoc
    ' Send non-rotated text to printer at same page location
    'result = TextOut(hPrintD c, 1000, 1000, OutString, Len(OutString))
    result = EndPage(hPrintD c) 'End the page
    result = EndDoc(hPrintDc ) 'End the print job
    result = EndDoc(hMemoryD C)
    result = DeleteDC(hPrint Dc) 'Delete the printer device context
    result = DeleteObject(hF ont) 'Delete the font object
    result = DeleteDC(hMemor yDC)
    Current, it's printing 2 files.
    File 1 contains image
    File 2 contains text

    How can i print 1 file contains image and text?
    Thanks
Working...