简体   繁体   中英

Choosing Correct papersize when printing with .NET PrintDocument

When I am looping through each page I need to decide the size of a page and choose what size to print it in. is there an easy way to determine what size they are suppose to be? right now i was going by the ratio of width and height. If ratio >= 1.64 && ratio <= 1.65 Then Legal Size, If ratio >= 1.29 && ratio <= 1.30 The Letter Size. but how about if they are printing other sizes do i have to do this for each one?

There are several different things that can be considered the "size of a page": PrintDocument.DefaultPageSettings is the default page settings from the printer driver. To determine "what size to print" I suggest using PrintDocument.DefaultPageSettings.PrintableArea.Size rather than the aspect ratio.

If you display a print controller this can be overridden on each page; use the PrintPage event's PrintPageEventArgs.PageSettings.PrintableArea.Size .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM