C# 将打印机首选项-页面方向设置为横向
我想将页面方向设置为横向,以便从excel Vsto项目打印excel工作表。从“打印”窗体弹出的打印机首选项窗口中手动设置页面方向 我需要一些自动化,这将设置方向景观每次用户给打印命令 我注意到,如果我从excel应用程序中将方向设置为横向,那么如果我想从MS word应用程序打印,方向保持不变,反之亦然。因此,必须有某种标志,可以从任何简单的winform应用程序更改C# 将打印机首选项-页面方向设置为横向,c#,winforms,printing,landscape-portrait,C#,Winforms,Printing,Landscape Portrait,我想将页面方向设置为横向,以便从excel Vsto项目打印excel工作表。从“打印”窗体弹出的打印机首选项窗口中手动设置页面方向 我需要一些自动化,这将设置方向景观每次用户给打印命令 我注意到,如果我从excel应用程序中将方向设置为横向,那么如果我想从MS word应用程序打印,方向保持不变,反之亦然。因此,必须有某种标志,可以从任何简单的winform应用程序更改 有什么方法可以操作这些属性吗?您可以尝试下面的方法 public void CustPrinting() { tr
有什么方法可以操作这些属性吗?您可以尝试下面的方法
public void CustPrinting()
{
try
{
strPrint = new StreamReader (filePath);
try
{
printFont = new Font("Arial", 10);
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.PrinterSettings.PrinterName = printer;
// Set the page orientation to landscape.
pd.DefaultPageSettings.Landscape = true;
pd.Print();
}
finally
{
strPrint.Close() ;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
我找不到任何方法可以自定义任何单个打印机的打印机设置。这是我在EXCEL应用程序中使用的代码
CommonData.\u WORKBOO
K是一个静态工作簿对象
Worksheet ws = CommonData._WORKBOOK.Application.ActiveSheet as Worksheet;
var _with1 = ws.PageSetup;
_with1.Orientation = Microsoft.Office.Interop.Excel.XlPageOrientation.xlLandscape;
CommonData._WORKBOOK.Application.Dialogs[Microsoft.Office.Interop.Excel.XlBuiltInDialog.xlDialogPrint].Show(Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);