954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Page configuration for printing

Hi, i'm trying to implement a print function and i can print a single string out but i'm having trouble configuring the page setup properly, mainly moving to a new line when the margin of the page is reached and moving to a new lines for each string in a list of string.

so far i have this printing out a single piece of text:

private void document_PrintPage(object sender,
        System.Drawing.Printing.PrintPageEventArgs e)
        {
            System.Drawing.Font printFont = new System.Drawing.Font
            ("Arial", 28, System.Drawing.FontStyle.Regular);

            string text = "Now then";
            // Draw the content.
            e.Graphics.DrawString(text.ToString(), printFont, System.Drawing.Brushes.Black, 10, 10);
        }


i've tried looking on the internet but musent be using the right search criteria because i can only find stuff to print one small string.

Any suggestions of how to do the above or suggestions of tutorials will be great

thanks

ChrisHunter
Posting Whiz in Training
276 posts since Feb 2011
Reputation Points: 36
Solved Threads: 28
 

Try this method: http://msdn.microsoft.com/en-us/library/21kdfbzs.aspx
Now it all boils down calculating a new RectangleF below the one you already have, if you want a newline.
Remember to take the page rectangle into account when you do a newline at the bottom of the print page!
EDIT: Oh and on line 9 you don't have to do text.ToString(), because text is already a string.

ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
 

Well spotted on the line 9. thanks i'll have a crack with your suggestion. any other suggestions are welcome

ChrisHunter
Posting Whiz in Training
276 posts since Feb 2011
Reputation Points: 36
Solved Threads: 28
 

That did it thanks for you help

ChrisHunter
Posting Whiz in Training
276 posts since Feb 2011
Reputation Points: 36
Solved Threads: 28
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: