How to set A4 size in WPF user management?

I have a custom "canvas" (MyUserControl) in WPF.

I need to set this β€œcanvas” to paper size (A3, A4, etc. or even custom).

How to convert A4 to Width and Height in MyUserControl?

+4
source share
3 answers

as stated here , I can do (for A4):

 Height="29.7cm" Width="21cm" 

even if the code is complicated ...

+14
source

I may not understand your question correctly, but MSDN defines Width / Height as

"This value is interpreted as a device independent measurement (1/96th inch). Strings do not have to contain decimal points. For example, a value of 1 is acceptable.

see FrameworkElement.Height

Based on the 1/96th Inch module, you can simply convert the paper size to a px view.

NTN

- hennson

+2
source

To set the size for printing A4

A4 Width = (8 * 96) px Height = (11.5 * 96) px

A3 = just double the width (16 * 96) px

Do not forget about the border of the printer, but A4 will always print above

I know that everything nowadays is a metric, but math is easier to use inches.,.

A4 = 297 mm * 210 mm, but also 8 "* 11.5", so the above math works!

0
source

Source: https://habr.com/ru/post/1402208/


All Articles