Click here to Skip to main content
11,582,850 members (72,287 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0 printing
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.
Posted 1-Feb-13 19:40pm
pankzn552
Edited 1-Feb-13 19:42pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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

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

  Print Answers RSS
0 OriginalGriff 335
1 Sergey Alexandrovich Kryukov 220
2 Andy Lanng 124
3 virusstorm 109
4 Kornfeld Eliyahu Peter 90
0 OriginalGriff 1,358
1 Sergey Alexandrovich Kryukov 970
2 Abhinav S 671
3 F-ES Sitecore 505
4 Suvendu Shekhar Giri 448


Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 4 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100