Printing win32ui and win32print on the same page or doc to minimise spcae between. Note: POS Printer
21:51 11 Jun 2026

I have:

def print_logo(printer_name):
    PHYSICALWIDTH = 30
    PHYSICALHEIGHT = 30

    file_name = "logo.png"

    hDC = win32ui.CreateDC ()
    hDC.CreatePrinterDC (printer_name)
    printer_size = hDC.GetDeviceCaps (PHYSICALWIDTH), hDC.GetDeviceCaps (PHYSICALHEIGHT)

    bmp = Image.open (file_name)
    
    hDC.StartDoc (file_name)
    hDC.StartPage ()

    dib = ImageWin.Dib (bmp)
    dib.draw (hDC.GetHandleOutput (), (80,0,printer_size[0]+200,printer_size[1]+0))

    hDC.EndPage ()
    hDC.EndDoc ()
    hDC.DeleteDC ()

and

        try:
            hJob = win32print.StartDocPrinter(hPrinter, 1, ("INVOICE RECEIPT", None, raw_type))
            # -----------------------------------------------------------------------------
            # -----PRINT TEXT BEFORE LOGO
            # -----------------------------------------------------------------------------
            try:
                win32print.StartPagePrinter(hPrinter)
                win32print.WritePrinter(hPrinter, before_logo)
                
            except Exception as e:
                message = f"Error printing! {e}"
                custome_status = "Error"
                return custome_status, message
            finally:
                win32print.EndDocPrinter(hPrinter)

            # -----------------------------------------------------------------------------
            # -----PRINT LOGO
            # -----------------------------------------------------------------------------
            print_logo(printer_name)

This works but it leaves a tone of space between the text and the logo, and i know its because sending 2 diffrent jobs on diffrent pages, how can i print them on the same page.
NOTE: There is win32ui for images and win32print for text

python-3.x win32ui