如何在C#中打印多个副本



我当前正在使用以下代码从数据库打印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();

}

使用打印机并通过

pd.PrinterSettings.Copies = [numberofpages]

您可以使用PrintToprointer选项如下

public virtual void PrintToPrinter (
    int nCopies,
    bool collated,
    int startPageN,
    int endPageN
)
Parameters
nCopies
Indicates the number of copies to print.
collated
Indicates whether to collate the pages.
startPageN
Indicates the first page to print.
endPageN
Indicates the last page to print.
https://learn.microsoft.com/en-us/previous-versions/ms226031(v=vs.90)

相关内容

  • 没有找到相关文章

最新更新