Отображение printDocument перед печатью / Как определить PoinF

Я использую PrintDialog и PrintDocument в приложении C# Windows, WinForms, чтобы напечатать документ.

Печать работает нормально, но я хочу отобразить документ перед печатью, чтобы я мог проверить, является ли PointF для DrawString таким, каким я его хочу. Как я могу это сделать? Есть ли какой-нибудь инструмент, позволяющий легко определить pointF на документе A4?

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));
    }      

1 ответ

Есть простой способ. Добавить printPreviewDialog и укажите путь к документу.printPreviewDialog1.Document = printDocument1;

Вы найдете больше информации здесь.

Другие вопросы по тегам