Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void GetDefaultPaperSize()
- {
- var devMode = PInvoke.PrinterHelper.GetPrinterDevMode(null);
- string s = String.Format("{0} : {1} x {2}", devMode.dmPaperSize, devMode.dmPaperWidth, devMode.dmPaperLength);
- Console.WriteLine(s);
- }
- void SetDefaultPaperSize()
- {
- string formName = "User defined";
- int paperWidth = 1016;
- int paperHeight = 2032;
- if (!PInvoke.PrinterHelper.IsPaperSize(formName, width, height))
- {
- PInvoke.PrinterHelper.PrinterSettingsInfo pd = new PInvoke.PrinterHelper.PrinterSettingsInfo();
- pd.Duplex = 0; // 不設定是否雙面列印(不設定即採預設值,以下類推)
- pd.Orientation = 0; // 不設定列印方向
- pd.pFormName = formName; // 紙張名字
- pd.pLength = height; // 設定印表機的高度
- pd.pWidth = width; // 設定印表機的寬度
- //pd.Size = PInvoke.PrinterHelper.PaperSize.DMPAPER_USER; // 自定義紙張
- PInvoke.PrinterHelper.ModifyPrinterSettings(printerName, ref pd); // 更改印表機設定
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement