Answer the question
In order to leave comments, you need to log in
How to print multiple pages?
I create a multi-page document, when I call the document preview window, all pages are displayed. But when I send the document to print, only the first page comes out. Can you tell me how to print all pages of a document?
private void button1_Click(object sender, EventArgs e)
{
printDocument.DocumentName = "Документ";
PaperSize pkCustomSize1 = new PaperSize("8.5x13", 550, 707);
this.printDocument.DefaultPageSettings.PaperSize = pkCustomSize1;
printDocument.PrinterSettings.DefaultPageSettings.PaperSize = GetPaperSize(5);
printDocument.PrintPage += PrintPageHandler;
PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
printPreviewDialog.Document = printDocument;
printPreviewDialog.ShowDialog();
PrintDialog printDialog1 = new PrintDialog();
printDialog1.Document = printDocument;
printDocument.PrinterSettings.PrintRange = PrintRange.AllPages;
if (printDialog1.ShowDialog()==DialogResult.OK)
printDocument.Print();
}
int PageNumber = 1;
void PrintPageHandler(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawString(result, new Font("Arial", 14), Brushes.Black, 0, 0);
e.Graphics.DrawImage(DownloadImageFromUrl("http://localhost/barcode.php?text=N233454E"), new Rectangle(new Point(20,5),new Size(200,39)));
e.Graphics.DrawImage(DownloadImageFromUrl("http://localhost/barcode.php?text=N233454E"), new Rectangle(new Point(280, 5), new Size(200, 39)));
e.Graphics.DrawImage(DownloadImageFromUrl("http://localhost/enterprise/naryadimg.php?idDoor=53590"), new Rectangle(new Point(10, 55), new Size(200, 200)));
if(PageNumber==2)
e.Graphics.DrawRectangle(new Pen(Color.Black), 10, 55, 200, 200);
if (PageNumber++ < 3)
e.HasMorePages = true;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question