0

I am using a PrintDialog and PrintDocument in c# windows application, WinForms, to print a document.

Printing working fine but I want to display the document before printing, so that I can check if PointF for DrawString is like I want it.How I can do that? Is there any tool that make it easy to define a pointF on A4 document?

private void buttonPrintShows_Click(object sender, EventArgs e)
        {
            PrintDialog pd = new PrintDialog();
            pd.Document = printDocumentStatistic;
            if (pd.ShowDialog() == DialogResult.OK)
            {
                printDocumentStatistic.Print();
            }
        }
private void printDocumentStatistic_PrintPage(object sender, PrintPageEventArgs e)
    {
        e.Graphics.DrawString("Shows:",new System.Drawing.Font("Arial", 20f), new SolidBrush(Color.Red), new PointF(35, 50));
        e.Graphics.DrawString("Act:", new System.Drawing.Font("Arial", 20f), new SolidBrush(Color.Red), new PointF(35, 75));
        e.Graphics.DrawString(show_name, new System.Drawing.Font("Arial", 20f), new SolidBrush(Color.Red), new PointF(100, 50));
        e.Graphics.DrawString(akt_name, new System.Drawing.Font("Arial", 20f), new SolidBrush(Color.Red), new PointF(100, 75));
    }      
Del boy
  • 97
  • 1
  • 14

1 Answers1

0

There is a simple way. Add a printPreviewDialog and give your document path to it. printPreviewDialog1.Document = printDocument1;

You will find more info here.

Roshana Pitigala
  • 8,437
  • 8
  • 49
  • 80