Click here to Skip to main content
15,895,667 members

printing more than one page to Windows fax and scan

Eddie Silva asked:

Open original thread
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:
C#
public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            
            foreach (string printer in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
                listBox1.Items.Add(printer);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            richTextBoxLink1.CreateDocument(printingSystem1);
            richTextBoxLink1.Print(listBox1.SelectedItem.ToString());
        }

        private void button2_Click(object sender, EventArgs e)
        {
            linesPrinted = 0;
            printDialog1.PrinterSettings.PrinterName = listBox1.SelectedItem.ToString();
            printDocument1.Print();
        }

        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)
            {
                e.Graphics.DrawString(richTextBox1.Lines[linesPrinted++],
                     richTextBox1.Font, brush, x, y);
                y += 15;
                if (y >= e.MarginBounds.Bottom)
                {
                    e.HasMorePages = true;
                    return;
                }
                else
                    e.HasMorePages = false;
            }
            e.Graphics.Flush(System.Drawing.Drawing2D.FlushIntention.Sync);
        }
    }

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?
Tags: C#, Printing

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900