Hi everyone, I am working on an application for invoicing, inventory management etc… I seem to be having a lot of trouble with printing, specifically using graphics clips off of the main graphics object supplied by the printer dialog.
Here is a little bit of code I put together to illustrate the problem.
Dim ps As New PrinterSetup
If ps.PageSetupDialog Then
Dim g As Graphics
g = OpenPrinterDialog(ps)
If g <> Nil Then
//g.DrawPicture(testimage, 0,0)
dim gclip1 as Graphics = g.Clip(0,0,150,100)
gclip1.DrawPicture(testimage, 0,0)
End If
End If
The problem is that when I draw the picture into the main graphics object everything works as I expect. The image prints into the upper left corner of the page just inside the 1 inch margins specified in my printer setup dialog. When I try to create a clip that is the dimensions of the image 150x80 at 0,0 of the main graphics object the image doesn’t print out at all. But when I increase the height of the clip to 20px greater than the height of the image It prints out just the very top left corner of the image, but it is in the position I would expect. If I draw into the clip but instead use margins of 0 in the printer setup dialog then the image prints out where I would expect, in the upper left corner of the page.
It almost seems like the x,y coordinates that xojo is using to draw the image are correct on the page, but where the clip actually lets through is not affected by the printer margins…
I imagine I am missing something stupid simple, but I have been trying to figure it out for the last 2 days and cannot seem to get anywhere.
All this testing was done on windows 10 with Xojo 2017 Release 2.1
Any Ideas?