Increasing paper height per iteration using printdocument

血红的双手。 提交于 2019-12-11 18:29:31

问题


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.


回答1:


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.
   }
}


来源:https://stackoverflow.com/questions/14659210/increasing-paper-height-per-iteration-using-printdocument

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!