使用printdocument增加每次迭代的纸张高度 [英] Increasing paper height per iteration using printdocument
本文介绍了使用printdocument增加每次迭代的纸张高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用printdocument进行打印输出。我希望在添加每一行后增加纸张的大小。我发现了一个类似的问题这里和这里。但解决方案不起作用。我使用Component类来覆盖Printdocument的基本方法,并在OnBeginPrint事件中设置页面大小
int pageHt = 288 ,pageWt = 314 跨度>;
受保护 覆盖 void OnBeginPrint (System.Drawing.Printing.PrintEventArgs e)
{
// 运行基本代码
base .OnBeginPrint(e);
base .DefaultPageSettings.PaperSize = new PaperSize( 自定义,pageWt,pageHt);
base .DefaultPageSettings.Landscape = false ;
}
然后每次迭代我试图增加纸张高度
base .DefaultPageSettings.PaperSize.Height + = 22 ;
但纸张高度不会增加。帮助赞赏。 Thanx。
解决方案
经过2天的努力,我找到了这个问题的答案。这很简单
public void PrintEstimate(PrintPageEventArgs e)
{
e.PageSettings.PaperSize = new PaperSize( 自定义,pageWt,pageHt); // 初始化页面的高度和宽度
foreach (..)
{
/ * ...
在此处写下循环
...
...
* /
e.PageSettings.PaperSize.Height = e.PageSettings.PaperSize.Height + 22 ; < span class =code-comment> // foreach迭代,增加页面高度。
}
}
i m using printdocument for a printout. i want to increment the size of the paper after each row is added. I found a similar question here and here. But the solution doesnot work. I m using a Component class to override the base method of Printdocument and I m setting the page size in OnBeginPrint event
int pageHt = 288, pageWt = 314;
protected override void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e)
{
// Run base code
base.OnBeginPrint(e);
base.DefaultPageSettings.PaperSize = new PaperSize("Custom", pageWt, pageHt);
base.DefaultPageSettings.Landscape = false;
}
Then for each iteration i m trying to increase the paper height
base.DefaultPageSettings.PaperSize.Height += 22;
But the paper height does not increment. Help appreciated. Thanx.
解决方案
I found the answer to this question after struggling for 2 days. It was pretty simple
public void PrintEstimate(PrintPageEventArgs e) { e.PageSettings.PaperSize = new PaperSize("Custom", pageWt, pageHt);//initialize the height and width of the page foreach(.. ) { /* ... Write the loop here ... ... */ e.PageSettings.PaperSize.Height = e.PageSettings.PaperSize.Height + 22;// foreach iteration, increment the page height. } }
这篇关于使用printdocument增加每次迭代的纸张高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文