Hi! I am printing some text using the API function TextOut. The following code snippet shows how I am converting my coordinates to pixels:
Now when I select "PDF Creator" in the printer dialog, the printing results are as expected, but when I use a real printer, the text gets displaced. The larger CurrentX or CurrentY, the larger the displacement, so there seems to be a wrong factor (about 2.5% off). A friend of mine tested my code on his computer with his printer - same result!
I have no explanation why real printers and PDF printers behave differently!
VB6, Win 7
'The TextOut function expects the x and y coordinates in pixels
CurrentX = CurrentX / Printer.ScaleWidth * Printer.width / Printer.TwipsPerPixelX
CurrentY = CurrentY / Printer.ScaleHeight * Printer.Height / Printer.TwipsPerPixelY
hfontOld = SelectObject(hdc, hfont) 'No reference to Printer object beyond this line!
TextOut hdc, CurrentX, CurrentY, Txt, Len(Txt) 'Printer.print cannot be used with API-defined fonts
CurrentX = CurrentX / Printer.ScaleWidth * Printer.width / Printer.TwipsPerPixelX
CurrentY = CurrentY / Printer.ScaleHeight * Printer.Height / Printer.TwipsPerPixelY
hfontOld = SelectObject(hdc, hfont) 'No reference to Printer object beyond this line!
TextOut hdc, CurrentX, CurrentY, Txt, Len(Txt) 'Printer.print cannot be used with API-defined fonts
Now when I select "PDF Creator" in the printer dialog, the printing results are as expected, but when I use a real printer, the text gets displaced. The larger CurrentX or CurrentY, the larger the displacement, so there seems to be a wrong factor (about 2.5% off). A friend of mine tested my code on his computer with his printer - same result!
I have no explanation why real printers and PDF printers behave differently!
VB6, Win 7