Several printing modes
In two of Visio development, we often need to print documents, which is a normal requirement, and the document object of Visio provides the following print modes:
Constant |
Value |
Description |
Visprintall |
prints all for Eground pages. |
visprintcurrentpage |
2 |
prints the active page. |
Visprintcurrentview |
4 |
prints the current View area. |
visprintfromto |
1 |
prints pages between the fromPage value and the ToPage value. |
visprintselection |
3< /td> |
prints a selection |
What do you mean by a few of the above? Below is a detailed explanation,Visprintall is the current document paging, if you have more than one page in the control, the use of the following methods:
VisPage.Document.PrintOut (Visprintoutrange.visprintall, 1, 1, False, "", False, Vispage.name, 1, false, false);
The Visprintcurrentview is to print out the form view content you see (generally rarely, because it may be intercepted to half of the area), as follows:
VisPage.Document.PrintOut (Visprintoutrange.visprintcurrentview, 1, 1, False, "", False, Vispage.name, 1, false, false);
Visprintselection is the print selection, which is useful when you select a part of the item and want to print it out. Note, however, that you want to make sure that you have selected the content, otherwise it will print out the contents of the entire control page, and its usage is as follows:
VisPage.Document.PrintOut (Visprintoutrange.visprintselection, 1, 1, False, "", False, Vispage.name, 1, false, false);
Other uses are similar, you can go down to try.
Another way to print is to print a part of a large page, which requires skill, first you need to get to the picture object of the page, convert to the Image object (how to convert it below), and then print a part of the entire image object, by locating the upper left corner, and the output rectangle size is OK.
Rectangle srcrect = new Rectangle (Dblleft, Dbltop, THIS.VISIOIMAGE.WIDTH/2, THIS.VISIOIMAGE.HEIGHT/2);
E.graphics.drawimage (This.visioimage, Destretangle, Srcrect, GraphicsUnit.Pixel);
The Picture property and transformation of Isio
When you print a Visio document, sometimes you need to preview what's going on, but it's also very simple, because the Page object you print has a Picture property, Can be used to display (Window.selection also has one such object, of course, it can be used to preview the selection). But don't be too happy to be here, because the picture object is IPictureDisp type, you need to convert to the image type that Picuturebox object can recognize, but this thing is not so easy to convert, hehe.
Fee Dickens, finally found the conversion method, the following introduction bar, lest everyone detours.
First set up a Axhostconverter conversion class, inherited from AxHost, as follows
public class Axhostconverter:axhost
{
Private Axhostconverter (): Base ("") {}
static public Image icturedisptoimage (stdole. IPictureDisp Picturedisp)
{
Return Getpicturefromipicture (PICTUREDISP);
}
}
When assigning values to PictureBox image objects, this is OK
pictureBox1.Image = Axhostconverter.picturedisptoimage (this.visPage.Picture);