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()
{
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?