Click here to Skip to main content
11,924,995 members (56,071 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# printing
I have a richTextBox with a long text that i need to send to fax using Windows fax and scan. this process works well if the text doesn't span more than one page, if it does it generates a tiff file that cannot be read

my code looks like:
public partial class Form1 : Form
        public Form1()
        private void Form1_Load(object sender, EventArgs e)
            foreach (string printer in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
        private void button1_Click(object sender, EventArgs e)
        private void button2_Click(object sender, EventArgs e)
            linesPrinted = 0;
            printDialog1.PrinterSettings.PrinterName = listBox1.SelectedItem.ToString();
        void doc_EndPrint(object sender, PrintEventArgs e)
        void doc_BeginPrint(object sender, PrintEventArgs e)
            linesPrinted = 0;
        private int linesPrinted = 0;
        void doc_PrintPage(object sender, PrintPageEventArgs e)
            int x = e.MarginBounds.Left;
            int y = e.MarginBounds.Top;
            Brush brush = new SolidBrush(richTextBox1.ForeColor);
            while (linesPrinted < richTextBox1.Lines.Length)
                     richTextBox1.Font, brush, x, y);
                y += 15;
                if (y >= e.MarginBounds.Bottom)
                    e.HasMorePages = true;
                    e.HasMorePages = false;
the form contains a button, a richtextbox and a list box. when running, select the fax (from windows fax and scan - windows 7) and press the button.

if I print to a normal printer or a pdf writer is fine, it only doesn't work with the fax, am I doing something wrong?
Posted 30-Aug-12 3:02am
Peter_in_2780 30-Aug-12 21:42pm
Are you missing an ...endPage() call somewhere? I don't know about the one you're using, but a lot of print APIs want one to flush this page and initialise the next.
Member 8219251 31-Aug-12 10:16am
HI Peter, thank you for your suggestion, the strange part is that if I select a normal printer or a pdf writer it prints correctly, so I am starting to think that it is a bug in the .Net framework.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151125.3 | Last Updated 30 Aug 2012
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