hallo,
I want to create a print preview for an invoice. What I'm having problems with is, most of the content in the print preview is pulled from a database and not the form, I am not sure how to implement this into the code, plus how would I change the font size, color, position...

private void preview_btn_Click(object sender, EventArgs e)
        {
            ThePrintDocument.PrintPage += 
                new System.Drawing.Printing.PrintPageEventHandler(PrintPage);
            string strText = "test" // HOW CAN I ADD FROM DB
            myStringReader = new System.IO.StringReader(strText);
            PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog();
            printPreviewDialog1.Width = 1100;
            printPreviewDialog1.Height = 900;
            printPreviewDialog1.Document = this.ThePrintDocument;
            printPreviewDialog1.ShowDialog();
        }

Recommended Answers

All 2 Replies

How can I use html tags in print preview?

the easier solution would be to use a WebBrowser and use it's documenttext property.

You can then use the ie's print preview and print functionnalities. If you one to have a nice html formatting. You could use xml + xslt or HtmlAgilityPack (http://htmlagilitypack.codeplex.com/)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.