Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
So now I'm stuck with Rich text box content not visible (readable) on print page (or print preview)
I'm using e.graphics to draw a table that I'm using to organize items and the rich text box should be one of the items stacked in the table (at the far end of each cell)
On the print preview, the rich text box borders are drawn but with no content inside and I tried lots of codes and sample but with no luck.
Preview: http://i.imgur.com/Ub5sKfn.jpg[^]

What I have tried:

C#
private void Doc_PrintPage(object sender, PrintPageEventArgs e)
{
    e.Graphics.SmoothingMode =
    SmoothingMode.AntiAlias;
    e.Graphics.TextRenderingHint =
        TextRenderingHint.AntiAliasGridFit;
    e.Graphics.InterpolationMode =
        InterpolationMode.High;
    float x = e.MarginBounds.Left;
    float y = e.MarginBounds.Top;
// Panel1 is the name of the panel that the table rest in
    Bitmap bmp = new Bitmap(this.panel1.Width, this.panel1.Height);
    this.panel1.DrawToBitmap(bmp, new Rectangle(0, 0, this.panel1.Width, this.panel1.Height));
    e.Graphics.DrawImage((Image)bmp, x, y);
}

private void PrintPreview_Click(object sender, EventArgs e)
        {
            PrintDocument doc = new PrintDocument();
            doc.PrintPage += this.Doc_PrintPage;
            Margins margins = new Margins(20, 20, 20, 10);
            doc.DefaultPageSettings.Margins = margins;
            printPreviewDialog1.Document = doc;
            printPreviewDialog1.ShowDialog();
        }
Posted

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