Asp.net winFrom custom print preview method

Source: Internet
Author: User
First, we define a PrintDocument object and implement the PrintPage method:
In the event of clicking a button, print and preview:
 
After you execute print preview, we will see the printed results:
 
Custom Print Preview
For custom print preview, you must set the attributes of the specified print controller PrintController.
PrintController is used by PrintDocument, which is usually not direct.
. NET Framework includes three print controllers derived from PrintController to help complete common tasks.
1. StandardPrintControllerPrint the document to the printer.
2. PreviewPrintControllerThe appearance preview during document printing is used by the PrintPreviewControl and PrintPreviewDialog classes.
3. PrintControllerWithStatusDialogA print status dialog box is provided during the printing process.
The code is as follows: Copy code
Manually implement a print preview function PreviewPrintControllerTo achieve
First, define PreviewPrintControllerAnd assigned to PrintDocument. Then print it.
GetPreviewPageInfo () is used to obtain a PreviewPageInfo array. The printed information is included in this array, and each image and information page is stored in the array.
The print information provided by the Image and PhysicalSize objects in the array: the size of an Image and the print page. The size of the printed image is different from that of the printed page. The size of the printed image is higher than that of the printed page. So we need to convert the size. The page is displayed. To print multiple pages, you only need to switch the PreviewPageInfo array.
When you need to display the print status dialog box, you can use PrintControllerWithStatusDialogPackage One PreviewPrintControllerTo display the print dialog box
PrintDocument. PrintController = new PrintControllerWithStatusDialog (previewController );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.