1. 程式人生 > >C#列印預覽時更改預設邊距,並設定預設的寬高

C#列印預覽時更改預設邊距,並設定預設的寬高

 new PrinterMargins(20,20,20,20,787,1129)

 

//此步最好在初始化,document 的時候就設定好邊距,否則後面邊距設定後,還有一些預設的X1,Y1非設定的值不會變化,會是預設的100,影響了列印時整個座標的結果。
            PrintDocument.DefaultPageSettings.Margins.Top = printerMargins.Top;
            PrintDocument.DefaultPageSettings.Margins.Bottom = printerMargins.Bottom;
            PrintDocument.DefaultPageSettings.Margins.Left = printerMargins.Left;
            PrintDocument.DefaultPageSettings.Margins.Right = printerMargins.Right
            PrinterMargins.Bottom = printerMargins.Bottom;
            PrinterMargins.Top = printerMargins.Top;
            PrinterMargins.Left = printerMargins.Left;
            PrinterMargins.Right = printerMargins.Right;
            PrinterMargins.Width = printerMargins.Width;
            PrinterMargins.Height = printerMargins.Height;