Is there any way to tell the printer object to print the image in the middle of the page, instead of the default of printing the image in the top left corner of the page?
Thanks.
Printable View
Is there any way to tell the printer object to print the image in the middle of the page, instead of the default of printing the image in the top left corner of the page?
Thanks.
Or so I believe..
Thanks for the info Paul. Now I can almost get the image centered on the page with
Private Sub mnuPrint_Click()
Picture1.CurrentX = ((Printer.ScaleWidth / 2) - (Picture1.Width / 2))
Picture1.CurrentY = ((Printer.ScaleHeight / 2) - (Picture1.Height / 2))
Printer.PaintPicture Picture1, Picture1.CurrentX, Picture1.CurrentY
Printer.EndDoc
End Sub
But there is still some very noticeable "off-centeredness" of the image. What I was attempting to do was change the current x to shift left half of the image width and the current y to shift upward half of the image height to center it on the page.
Is there some other attribute that I could use? as I am trying to make the image "auto-centerable" regardless of the image size. If it came down to it, I guess I could hard code the values into to print method as all of the images would be of the same size, but figured that I would try to make the mnuPrint_Click () function as widely applicable as possible.
I only mentioned the currentX and currentY because I had seen them referred to in other posts.
What scalemode is the printer object set to in your example?
The code I worte below and the code you wrote both produce the same output on my printer here.
The printer here is a laser printer (600dpi) but I guess the only things that would cause it to be off centre for you are:
Something screwy in the printer driver
OR The bitmap has a border on one or two sides that you cannot see in the printout (but you would see on the screen so it probably isn't that)
OR The printer has a low resolution so rounding causes the image to be slightly off (we're talking millimeters here though).
Sorry I can't be more authoritative on the subject.Code:Private Sub Command1_Click()
Form1.ScaleMode = Printer.ScaleMode
Dim x, y As Single
x = Printer.ScaleWidth / 2 - Picture1.Width / 2
y = Printer.ScaleHeight / 2 - Picture1.Height / 2
Picture1.Move x, y
Printer.PaintPicture Picture1.Picture, x, y
Printer.EndDoc
End Sub
Regards