Fahadjamal Jamaluddin

Fahadjamal Jamaluddin

  • 1.2k
  • 476
  • 11.5k

pdf file print by mvc.net

Jun 18 2021 1:21 PM

code run but printer 

print blank page            

 

var files = Directory.GetFiles(Server.MapPath("/Document"));
            if (files.Length != 0)
            {
                using (var pdoc = new PrintDocument())
                using (var pdi = new System.Windows.Forms.PrintDialog { Document = pdoc, UseEXDialog = false })
                {
                    // pdoc.PrinterSettings.PrinterName ="" ;
                    pdoc.PrinterSettings = pdi.PrinterSettings;
                    // ************************************
                    // Pay attention to the following line:
                    pdoc.PrintPage += pd_PrintPage;
                    // ************************************
                    foreach (var file in files)
                    {
                        pdoc.DocumentName = file;

                        pdoc.Print();
                    }

                }
            }


Answers (2)