Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
How i can print a lengthy string using C#?

im using
C#
myReader = new StringReader(strText);
           PrintDocument p = new PrintDocument();
           p.PrintPage += delegate(object sender1, PrintPageEventArgs ev)
             {

                    ev.Graphics.DrawString(//parameters)
              };


           try
           {
               p.Print();
           }
           catch (Exception ex)
           {
               throw new Exception("Exception Occurred While Printing", ex);
           }


here using ev.Graphics.DrawString() method but..
its getting error TextWrapping is not occuring to this..
for that issue i just added new RectangleF() inside Drawstring(//here like new RectangleF(00,00,00,00)
>00 means its only for demo purpose.
after this RectangleF()implementation its only print one page and it will get wrapped output but its printing occur only for one page

if more clear will tell you detail.
thanks
Hoping for your comment and reply..
Posted

1 solution

Co-incidentally, I just replied to one of teh query just now...

Check
Textwrapping while printing[^]

You need to use Graphics.DrawString Method (String, Font, Brush, RectangleF, StringFormat)

Hope that helps
Milind
 
Share this answer
 
Comments
indhukanth 15-Jan-13 4:47am    
im using the same, but its not working for my need.
in Drawstring() its support RectangleF() but if length of the string is excced more than one page then its will not work.. please check.

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