Print output regardless of printer resolution

Windows specific forum
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by teachco.

;PrintTextAndImage - by Andreas Schleitzer
;Please send comments to [url]mailto:aschleitzer@teachco.de[/url]
;=======================================================
;Using some code from Paul Leischow. Thank you.
;=======================================================
;This code will resize text, positions and a BMP so
;that it prints the same size on all printers regardless
;of printer resolution.
;
; pfi - print factor image
; pft - print factor text and position
; xps - x resize factor
; yps - y resize factor
;
;=======================================================
;
If LoadImage(1,"test.bmp")
If PrintRequester()
pfi.f=(ImageWidth()*1.39)/PrinterPageWidth()

xrf.f=ImageWidth()/pfi
yrf.f=ImageHeight()/pfi
ResizeImage(1,xrf,yrf)

If StartPrinting("Print Job Text and Image")
If StartDrawing(PrinterOutput())
pft.f = PrinterPageHeight()/1086.72
DrawImage(UseImage(1),200*pft,200*pft)
DrawingFont(LoadFont(0, "Arial", Int(11*pft)))
Locate(10*pft, 10*pft) : DrawText("PureBasic Printer Test")
DrawingFont(LoadFont(0, "Arial", Int(20*pft)))
Locate(10*pft, 100*pft) : DrawText("PureBasic Printer Test 2")
Locate(10*pft, 200*pft)
Box(20*pft, 60*pft, Int(40*pft), Int(40*pft))
StopDrawing()
EndIf
StopPrinting()
EndIf
MessageRequester("Print","Data has been sent to Printer",#MB_ICONINFORMATION)
EndIf
Else
MessageRequester("Print","Image not found",#MB_ICONINFORMATION)
EndIf
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by teachco.

The text sizes in the code (ARIAL 11 and 20) are the same like in WinWord 2ooo - I hope. Test it and send me your comment!
Post Reply