展开全部
//打印方向(纵/横)
this.PrintDoc.DefaultPageSettings.Landscape = false;
//设置纸张类型
string papername = ps.Attributes["papername"].Value;
int paperWidth = Convert.ToInt32(ps.Attributes["paperwidth"].Value);
int paperHeight = Convert.ToInt32(ps.Attributes["paperheight"].Value);
this.PrintDoc.DefaultPageSettings.PaperSize = new PaperSize(papername, paperWidth, paperHeight);
//打印机设置
// this.printDoc.PrinterSettings.PrinterName = ps["Printer"].InnerText.Trim();
//边距,上下左右
int leftMargin = int.Parse(ps.Attributes["left"].Value.Trim());
int topMargin = int.Parse(ps.Attributes["top"].Value.Trim());
int rightMargin = int.Parse(ps.Attributes["right"].Value.Trim());
int bottomMargin = int.Parse(ps.Attributes["bottom"].Value.Trim());
PrintDoc.DefaultPageSettings.Margins = new Margins(leftMargin, rightMargin, topMargin, bottomMargin);
this.PrintDoc.DefaultPageSettings.Landscape = false;
//设置纸张类型
string papername = ps.Attributes["papername"].Value;
int paperWidth = Convert.ToInt32(ps.Attributes["paperwidth"].Value);
int paperHeight = Convert.ToInt32(ps.Attributes["paperheight"].Value);
this.PrintDoc.DefaultPageSettings.PaperSize = new PaperSize(papername, paperWidth, paperHeight);
//打印机设置
// this.printDoc.PrinterSettings.PrinterName = ps["Printer"].InnerText.Trim();
//边距,上下左右
int leftMargin = int.Parse(ps.Attributes["left"].Value.Trim());
int topMargin = int.Parse(ps.Attributes["top"].Value.Trim());
int rightMargin = int.Parse(ps.Attributes["right"].Value.Trim());
int bottomMargin = int.Parse(ps.Attributes["bottom"].Value.Trim());
PrintDoc.DefaultPageSettings.Margins = new Margins(leftMargin, rightMargin, topMargin, bottomMargin);
追问
//边距,上下左右
写在哪的??
printDocument1_PrintPage 下面??
可以给页边距赋值吗??怎么符
帮我解答完 我会加分 的 真心谢谢
追答
打印之前都可以的,因为设置的是PrintDoc,上面的代码最后设置的是边距
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询