Ideal for testing printer output without wasting dead trees or unicorn blood.
(I made this for testing before printing on a ticket printer)
Code: Select all
Enumeration FormFont
#Font_printer
EndEnumeration
Procedure init_printer()
CompilerIf #PB_Compiler_Debugger
UsePNGImageDecoder()
Define printer_out=OpenWindow(-1, 0, 0, 500, 650, "Ticket", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Define s=576/38
Define printer_font=LoadFont(-1,"Courier New",s)
StartDrawing(WindowOutput(printer_out))
FrontColor(RGB(0,0,0))
BackColor(RGB(255,255,255))
DrawingFont(FontID(printer_font))
CompilerElse
DefaultPrinter()
Define s=PrinterPageWidth()/38
StartPrinting("KISS-TPV+")
UsePNGImageDecoder()
Define printer_font=LoadFont(-1,"Courier New",s)
Global printer_out=PrinterOutput()
StartDrawing(printer_out)
BackColor(RGB(255, 255, 255)) ; Uses white as back color, usuful when printing on a white sheet
FrontColor(RGB(0, 0, 0)) ; Use black for standard text color
DrawingFont(FontID(printer_font))
CompilerEndIf
EndProcedure
Procedure close_printer()
Define event
CompilerIf #PB_Compiler_Debugger
StopDrawing()
Repeat
event=WaitWindowEvent()
Until event=#PB_Event_CloseWindow
CloseWindow(GetActiveWindow())
CompilerElse
StopDrawing()
StopPrinting()
CompilerEndIf
EndProcedure
init_printer()
Define y=0,yd=22
Define logo=LoadImage(-1,"gfx/PrinterLogo.png") ;HEADER LOGO
If logo<>0
DrawImage(ImageID(logo), 0, 0)
y=ImageHeight(logo)
EndIf
DrawText(0,y," "+FormatDate("%dd-%mm-%yyyy %hh:%ii",Date())):y+yd
DrawText(0,y,"-----------------------------------------"):y+yd
DrawText(0,y," JUST TESTING"):y+yd
DrawText(0,y,"-----------------------------------------"):y+yd
close_printer()