One other function is the PaintPicture method that allows you to output the contents of a graphics file to the printer object. The PaintPicture method uses this syntax:
Printer.PaintPicture picture, x1, y1, [width1], [height1], [x2], [y2],
[width2], [height2], [opcode]
I won't cover everything here, so if you want more info, open up the MSDN library and select 'PaintPicture method' from the Index list. Picture is a IPictureDisp class, which can be retreived from a PictureBox or Forms Picture property, or using LoadPicture.
x1 and y1 specify the coordinates where the picture should be placed on the page. Width1 and Height1 set the width and height of the picture to be outputted, respectively. x2 and y2, in combination with width2 and height2 can be used to specify a clipping area from the source image.
Take a look at the examples below.
This code below outputs the picture contained within Picture1 to the printer, with 1000 twip (if this is the current scale mode) margins.
Printer.PaintPicture Picture1.Picture, 1000, 1000
This code,
PaintPicture LoadPicture("C:sample.jpg"), 1000, 1000
loads the file C:sample.jpg and outputs it onto a page.
Finally,
Printer.PaintPicture Picture1.Picture, 1000, 1000, 2000, 2000
resizes the picture in Picture1 to 2000x2000 pixels, and prints it.
Comments