我目前正在使用以下代码从数据库中打印 pdf 文件。我使用 pdfium 来查看 pdf 文件和打印我使用 PrintDialog 框。我只能在一个副本中打印 pdf 文件,但在多个副本中我没有得到它
这是我的代码:
PrintDialog PrintDialog1 = new PrintDialog();
PrintDialog1.ShowDialog();
PrintDocument pd = new PrintDocument();
int pageForPrint = 0;
pd.PrintPage += (s, z) =>
{
using (PdfBitmap bmp = new PdfBitmap((int)z.PageSettings.PrintableArea.Width, (int)z.PageSettings.PrintableArea.Height, true))
{
//Render to PdfBitmap using page's Render method with FPDF_PRINTING flag
pdfViewer1.Document.Pages[pageForPrint].Render
(bmp,
0,
0,
(int)z.PageSettings.PrintableArea.Width,
(int)z.PageBounds.Height,
Patagames.Pdf.Enums.PageRotate.Normal, Patagames.Pdf.Enums.RenderFlags.FPDF_PRINTING);
//Draw rendered image to printer's graphics surface
z.Graphics.DrawImageUnscaled(bmp.Image,
(int)z.PageSettings.PrintableArea.X,
(int)z.PageSettings.PrintableArea.Y);
//Print next page
if (pageForPrint < pdfViewer1.Document.Pages.Count)
{
pageForPrint++;
z.HasMorePages = true;
}
;
}
};
//start printing routine
pd.Print();
}