|
|
@@ -39,7 +39,7 @@ namespace Dongke.WinForm.Controls.InvoiceLayout
|
|
|
private DataRow _printData = null;
|
|
|
private DataTable _printGridData = null;
|
|
|
|
|
|
- private PrintDocument _printDocument = new PrintDocument();
|
|
|
+ private PrintDocument _printDocument = null;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 0:正常,1:旋转180,
|
|
|
@@ -56,9 +56,6 @@ namespace Dongke.WinForm.Controls.InvoiceLayout
|
|
|
|
|
|
private InvoiceLayoutPrinter()
|
|
|
{
|
|
|
- _printDocument.DocumentName = "LayoutDocument";
|
|
|
- _printDocument.BeginPrint += new PrintEventHandler(this.printDocument_BeginPrint);
|
|
|
- _printDocument.PrintPage += new PrintPageEventHandler(this.PrintDocument_PrintPage);
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
@@ -130,8 +127,8 @@ namespace Dongke.WinForm.Controls.InvoiceLayout
|
|
|
try
|
|
|
{
|
|
|
//Logger.Debug("打印开始1");
|
|
|
- InvoiceLayoutPrinter printer = new InvoiceLayoutPrinter();
|
|
|
|
|
|
+ InvoiceLayoutPrinter printer = new InvoiceLayoutPrinter();
|
|
|
printer._printDirectionKind = printDirectionKind;
|
|
|
|
|
|
printer.LayoutItems = new List<LayoutItem>();
|
|
|
@@ -140,15 +137,23 @@ namespace Dongke.WinForm.Controls.InvoiceLayout
|
|
|
printer._printGridData = detail;
|
|
|
//Logger.Debug("打印开始2");
|
|
|
|
|
|
- printer._printDocument.PrinterSettings.PrinterName = printerName;
|
|
|
- printer._printDocument.PrinterSettings.Copies = copies;
|
|
|
|
|
|
- //Logger.Debug("打印开始3");
|
|
|
- printer._printDocument.Print();
|
|
|
- //Logger.Debug("打印开始4");
|
|
|
+ using (printer._printDocument = new PrintDocument())
|
|
|
+ {
|
|
|
+ printer._printDocument.DocumentName = "LayoutDocument";
|
|
|
+ printer._printDocument.BeginPrint += new PrintEventHandler(printer.printDocument_BeginPrint);
|
|
|
+ printer._printDocument.PrintPage += new PrintPageEventHandler(printer.PrintDocument_PrintPage);
|
|
|
|
|
|
- //return printer.DrawImages().ToArray();
|
|
|
- //return printer.DrawImages();
|
|
|
+ printer._printDocument.PrinterSettings.PrinterName = printerName;
|
|
|
+ printer._printDocument.PrinterSettings.Copies = copies;
|
|
|
+
|
|
|
+ //Logger.Debug("打印开始3");
|
|
|
+ printer._printDocument.Print();
|
|
|
+ //Logger.Debug("打印开始4");
|
|
|
+
|
|
|
+ //return printer.DrawImages().ToArray();
|
|
|
+ //return printer.DrawImages();
|
|
|
+ }
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|