Click here to Skip to main content
15,887,273 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to print multiple image when print items are increasing. I used to print item by using ex.

C#
graphic.DrawString("Name of the client/organization", new Font("Courier New", 11, FontStyle.Bold), new SolidBrush(Color.Black), startX + 40, startY + 70);
graphic.DrawString(": " + NameofClient.Text, new Font("Courier New", 11), new SolidBrush(Color.Black), startX + 370, startY + 70);


here all the items(see the image ) just print string using graphic.drawsting. i want only if menu items increase jump in to the second page

What I have tried:

and I try with the e.HasMorePages = true but it count infinity when printing.

I want to know what is the better way to print multiple page.
Posted
Comments
Sergey Alexandrovich Kryukov 11-Feb-16 14:02pm    
Your code sample has nothing to do with "it count infinity" problem. But isn't it obvious that having hard-coded immediate constant true cannot work to finilize printing? :-)
—SA

1 solution

Please see my comment to the question. It should obvious that having hard-coded immediate constant true cannot work to finilize printing. When you need more pages, it should be true, and eventually it should become false. I don't know what else needs explanation.

Please see:
PrintPageEventArgs Class (System.Drawing.Printing)[^],
PrintPageEventArgs.HasMorePages Property (System.Drawing.Printing)[^].

In your case, the case of multiple pages, the right-part operand of assignement should be calculated on condition:
C#
void myPrintPageHandler(object sender, PrintPageEventArgs ev) {
   // ...
   ev.HasMorePages = !AllPagesArePrinted(ev);
   // where the function AllPagesArePrinted(ev) is on your, it depends on your logic
}


—SA
 
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