private bool pRefreshObjClient(int iPage, cIPrintClient objClient) { if (objClient == null) { return true; } else { return objClient.printingPage(iPage); } }
private bool pDoPrint(cIPrintClient objClient) { try { int copies = 0; int q = 0; pCreatePaint(); m_rePaintObject = true; cPrinter printer = null; // if the printer is not defined // if (m_report.getLaunchInfo().getPrinter() == null) { printer = cPrintAPI.getcPrinterFromDefaultPrinter(null); } // we use the printer asigned by the caller // else { printer = m_report.getLaunchInfo().getPrinter(); } cReportLaunchInfo w_launchInfo = m_report.getLaunchInfo(); copies = w_launchInfo.getCopies(); if (w_launchInfo.getShowPrintersDialog()) { printer.setCopies(copies); if (!printer.showDialog(m_report.getPages().count())) { return false; } copies = printer.getCopies(); } else { printer.getPaperInfo().setPagesToPrint("1-" + m_report.getPages().count().ToString()); } for (q = 0; q < copies; q++) { if (!printPagesToPrinter(printer, objClient)) { return false; } } return true; } catch (Exception ex) { cError.mngError(ex, "pDoPrint", C_MODULE, ""); return false; } finally { if (m_rpwPrint != null) { printPage(m_currPage, false); m_rpwPrint.getBody().Refresh(); } } }
private bool printPagesToPrinter(cPrinter printer, cIPrintClient objClient) { try { PrintDocument printDoc = new PrintDocument(); cReportPaperInfo w_paperInfo = m_report.getPaperInfo(); if (!printer.starDoc(printDoc, m_report.getName(), w_paperInfo.getPaperSize(), w_paperInfo.getOrientation())) { return false; } printDoc.PrintPage += new PrintPageEventHandler(printPage); printDoc.PrinterSettings.PrinterName = printer.getDeviceName(); //PrintDialog printDialog = new PrintDialog(); //printDialog.Document = printDoc; //DialogResult dialogResult = printDialog.ShowDialog(); //if (dialogResult == DialogResult.OK) //{ m_pageToPrint = -1; m_pagesToPrint = pGetPagesToPrint(printer.getPaperInfo().getPagesToPrint()); m_objClientToPrint = objClient; printDoc.Print(); //} /* for (i = 0; i < m_report.getPages().count(); i++) { if (pHaveToPrintThisPage(i, vPages)) { if (!printer.starPage()) { throw new ReportPaintException(csRptPaintErrors.CSRPT_PAINT_ERR_PRINTING, C_MODULE, "Ocurrio un error al imprimir el reporte." ); } printPage(i, true); if (!drawPage(printer)) { return false; } if (!printer.endPage()) { throw new ReportPaintException(csRptPaintErrors.CSRPT_PAINT_ERR_PRINTING, C_MODULE, "Ocurrio un error al imprimir el reporte." ); } if (!pRefreshObjClient(i, objClient)) { return false; } } } if (!printer.endDoc()) { throw new ReportPaintException(csRptPaintErrors.CSRPT_PAINT_ERR_PRINTING, C_MODULE, "Ocurrio un error al imprimir el reporte." ); } */ return true; } catch (Exception ex) { cError.mngError(ex, "printPagePrinter", C_MODULE, ""); return false; } }
public bool doPrint(cIPrintClient objClient) { return pDoPrint(objClient); }