Click here to Skip to main content
15,909,437 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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


C#
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
C#
base.DefaultPageSettings.PaperSize.Height += 22;


But the paper height does not increment. Help appreciated. Thanx.
Posted
Updated 1-Feb-13 19:42pm
v2

1 solution

I found the answer to this question after struggling for 2 days. It was pretty simple

C#
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.
   }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900