public UCCustomerManager() { InitializeComponent(); UIAssistants.SetButtonStyle4QueryAndClear(btn_query, btn_clear, true); //设置查询按钮和清除按钮样式 DataGridViewEx.SetDataGridViewStyle(dgv_table, create_time); //设置数据表格样式,并将最后一列填充其余空白 Load += (sender, args) => UIAssistants.SetDataGridViewCheckColumn(dgv_table, colCheck); Init(); //初始化方法 SetContentMenuScrip(dgv_table); #region 预览、打印设置 string printObject = "tb_customer"; string printTitle = "客户档案"; List<string> listNotPrint = new List<string>(); listNotPrint.Add(cust_id.Name); //listNotPrint.Add(v_brand.Name); PaperSize paperSize = new PaperSize(); paperSize.Width = 297; paperSize.Height = 210; businessPrint = new BusinessPrint(dgv_table, printObject, printTitle, paperSize, listNotPrint); #endregion }
public void print() { PrintDialog pd = new PrintDialog(); PrintDocument pdoc = new PrintDocument(); PrinterSettings ps = new PrinterSettings(); Font font =new Font("Arial",12); PaperSize psize = new PaperSize("Custome", 100, 200); pd.Document = pdoc; pd.Document.DefaultPageSettings.PaperSize = psize; pdoc.DefaultPageSettings.PaperSize.Height = 320; pdoc.DefaultPageSettings.PaperSize.Width = 200; pdoc.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage); DialogResult result = pd.ShowDialog(); if (result == DialogResult.OK) { PrintPreviewDialog ppd = new PrintPreviewDialog(); ppd.Document = pdoc; result = ppd.ShowDialog(); if (result == DialogResult.OK) { pdoc.Print(); } } }
BusinessPrint businessPrint;//业务打印功能 #endregion #region 初始化窗体 public UCOldPartsSendManager() { InitializeComponent(); BindOrderStatus(); UIAssistants.SetButtonStyle4QueryAndClear(btnQuery, btnClear); //设置查询按钮和清除按钮样式 base.AddEvent += new ClickHandler(UCOldPartsReceiptManager_AddEvent); base.CopyEvent += new ClickHandler(UCOldPartsReceiptManager_CopyEvent); base.EditEvent += new ClickHandler(UCOldPartsReceiptManager_EditEvent); base.DeleteEvent += new ClickHandler(UCOldPartsReceiptManager_DeleteEvent); base.ViewEvent += new ClickHandler(UCOldPartsReceiptManager_ViewEvent); base.VerifyEvent += new ClickHandler(UCOldPartsReceiptManager_VerifyEvent); base.SubmitEvent += new ClickHandler(UCOldPartsReceiptManager_SubmitEvent); base.PrintEvent += new ClickHandler(UCOldPartsSendManager_PrintEvent); base.SetEvent += new ClickHandler(UCOldPartsSendManager_SetEvent); SetQuick(); base.SetContentMenuScrip(dgvRData); #region 预览、打印设置 string printObject = "tb_maintain_oldpart_receiv_send_O"; string printTitle = "旧件发货单"; List<string> listNotPrint = new List<string>(); listNotPrint.Add(oldpart_id.Name); //listNotPrint.Add(v_brand.Name); PaperSize paperSize = new PaperSize(); paperSize.Width = 297; paperSize.Height = 210; businessPrint = new BusinessPrint(dgvRData, printObject, printTitle, paperSize, listNotPrint); #endregion }
public PageSettings PrtSetUp(PrintDocument printDocument) { //声明返回值的PageSettings PageSettings ps = new PageSettings(); //申明并实例化PageSetupDialog PageSetupDialog psDlg = new PageSetupDialog(); System.Drawing.Printing.PaperSize size = new System.Drawing.Printing.PaperSize("挂号打印", 472, 276); try { //相关文档及文档页面默认设置 psDlg.Document = printDocument; psDlg.PageSettings = printDocument.DefaultPageSettings; psDlg.PageSettings.PaperSize = size; ps = psDlg.PageSettings; printDocument.DefaultPageSettings = psDlg.PageSettings; } catch (Exception ex) { MessageBox.Show(ex.ToString(), "出现打印错误"); } finally { psDlg.Dispose(); psDlg = null; } return(ps); }
private void fmPrintMap_FormClosed(object sender, FormClosedEventArgs e) { if (m_bShowPrintDialog) { System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument(); pd.PrinterSettings.PrinterName = cboPrinters.SelectedItem.ToString(); System.Drawing.Printing.PaperSize pkSize = new System.Drawing.Printing.PaperSize(); //bool bPaperSizeAllowed = false; //string sPaperSizes = ""; //for (int i = 0; i < pd.PrinterSettings.PaperSizes.Count; i++) //{ // //System.Windows.Forms.MessageBox.Show(pd.PrinterSettings.PaperSizes[i].PaperName.ToString()); // if (pd.PrinterSettings.PaperSizes[i].PaperName.Contains(this.cboMapSize.SelectedItem.ToString())) // { // bPaperSizeAllowed = true; // //break; // } //} if (System.Windows.Forms.MessageBox.Show("Would you like to print this map now?", "Medford Print Map", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { object missing = Type.Missing; //if (bPaperSizeAllowed) showPrintDialog(cboPrinters.SelectedItem.ToString()); //this.App.ShowDialog((int)esriMxDlgIDs.esriMxDlgPrintSetup, ref missing); // //else // this.App.ShowDialog((int)esriMxDlgIDs.esriMxDlgPageSetup,ref missing); //showPageSettingDialog(cboPrinters.SelectedItem.ToString()); } //System.Windows.Forms.MessageBox.Show(sPaperSizes); } }
public void loadReport() { /* // file ini disimpan di bin/debug m_cryRpt.Load(Application.StartupPath + @".\REPORT\RESI.rpt"); // cara pemanggilan menggunakan data table yang sudah di proses dan di masukan ke object dt m_cryRpt.Database.Tables[0].SetDataSource((DataTable)my_dt); // data yang di panggil di ke data source otomatis tergambar ke dataset yang di buat dan berextensi xsd crystalReportViewerRESI.ReportSource = m_cryRpt; crystalReportViewerRESI.Refresh(); */ reportViewerCETAKRESI.LocalReport.DataSources.Clear(); reportViewerCETAKRESI.LocalReport.ReportEmbeddedResource = "LOGISTICMANAGAMENTSYSTEM.REPORTS.EXPRESS.cetakRESI.rdlc"; Microsoft.Reporting.WinForms.ReportDataSource dataset = new Microsoft.Reporting.WinForms.ReportDataSource("dsRESI_V_TRANSAKSIEXPRESS", my_dt); // set the datasource reportViewerCETAKRESI.LocalReport.DataSources.Add(dataset); dataset.Value = my_dt; System.Drawing.Printing.PageSettings pg = new PageSettings(); // Set margins // Set paper size pg.Margins.Top = 100; pg.Margins.Bottom = 100; pg.Margins.Left = 100; pg.Margins.Right = 100; pg.Landscape = false; System.Drawing.Printing.PaperSize size = new PaperSize(); size.RawKind = (int)PaperKind.A4; pg.PaperSize = size; // reportViewerCETAKRESI.SetPageSettings(pg); ?? reportViewerCETAKRESI.LocalReport.Refresh(); reportViewerCETAKRESI.RefreshReport(); // refresh report }
public UCVehicleManage() { InitializeComponent(); UIAssistants.SetButtonStyle4QueryAndClear(btnQuery, btnClear); //设置查询按钮和清除按钮样式 base.DeleteEvent += new ClickHandler(UCVehicleManage_DeleteEvent); base.EditEvent += new ClickHandler(UCVehicleManage_EditEvent); base.CopyEvent += new ClickHandler(UCVehicleManage_CopyEvent); base.AddEvent += new ClickHandler(UCVehicleManage_AddEvent); base.StatusEvent += new ClickHandler(UCVehicleManage_StatusEvent); base.ViewEvent += new ClickHandler(UCVehicleManage_ViewEvent); base.ExportEvent -= new ClickHandler(UC_ExportEvent); base.ExportEvent += new ClickHandler(UC_ExportEvent); base.PrintEvent += new ClickHandler(UCVehicleManage_PrintEvent); base.SetContentMenuScrip(dgvData); SetQuick(); #region 预览、打印设置 string printObject = "tb_vehicle"; string printTitle = "车辆档案"; List<string> listNotPrint = new List<string>(); listNotPrint.Add(v_id.Name); //listNotPrint.Add(v_brand.Name); PaperSize paperSize = new PaperSize(); paperSize.Width = 297; paperSize.Height = 210; businessPrint = new BusinessPrint(dgvData, printObject, printTitle, paperSize, listNotPrint); #endregion }
void setPrintDocument(PrinterSettings PrnSet, PageSettings PageSet) { bool Landscape = (ModuleReport["orientation"].ToString().ToUpper() == "P"); PrnSet.DefaultPageSettings.Landscape = Landscape; PageSet.Landscape = Landscape; string papersize = ModuleReport["papersize"].ToString(); if (papersize == "") { papersize = "A4"; } if (papersize.ToUpper() == "A3") { System.Drawing.Printing.PaperSize A3pSize = findSuitablePaperSize( GetSystemSize(CrystalDecisions.Shared.PaperSize.PaperA3), PaperKind.A3, PrnSet.PaperSizes); if (A3pSize != null) { PrnSet.DefaultPageSettings.PaperSize = A3pSize; PageSet.PaperSize = A3pSize; } } if (papersize.ToUpper() == "A4") { System.Drawing.Printing.PaperSize A4pSize = findSuitablePaperSize( GetSystemSize(CrystalDecisions.Shared.PaperSize.PaperA4), PaperKind.A4, PrnSet.PaperSizes); if (A4pSize != null) { PrnSet.DefaultPageSettings.PaperSize = A4pSize; PageSet.PaperSize = A4pSize; } } }
private void GetPrinters_Click(object sender, EventArgs e) { //PrintDocument pd = new PrintDocument(); //pd.DefaultPageSettings.Bounds = new //pd.Print(); PrintPreviewDialog ppd = new PrintPreviewDialog(); PrintDocument pd = new PrintDocument(); //设置边距 Margins margin = new Margins(200, 20, 20, 0); pd.DefaultPageSettings.Margins = margin; //纸张设置默认 PaperSize pageSize = new PaperSize("First custom size", getYc(58), 100); pd.DefaultPageSettings.PaperSize = pageSize; //打印事件设置 pd.PrintPage += pd_PrintPage; ppd.Document = pd; ppd.ShowDialog(); //try //{ // pd.Print(); //} //catch (Exception ex) //{ // MessageBox.Show(ex.Message, "打印出错", MessageBoxButtons.OK, MessageBoxIcon.Error); // pd.PrintController.OnEndPrint(pd, new PrintEventArgs()); //} }
private void btnPrint_Click(object sender, EventArgs e) { PrintDialog pd = new PrintDialog(); pdoc = new PrintDocument(); PrinterSettings ps = new PrinterSettings(); Font font = new Font("Courier New", 15); PaperSize psize = new PaperSize("Custom", 100, 200); pd.Document = pdoc; pd.Document.DefaultPageSettings.PaperSize = psize; pdoc.DefaultPageSettings.PaperSize.Height = 720; pdoc.DefaultPageSettings.PaperSize.Width = 620; pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage); DialogResult result = pd.ShowDialog(); if (result == DialogResult.OK) { PrintPreviewDialog pp = new PrintPreviewDialog(); pp.Document = pdoc; result = pp.ShowDialog(); if (result == DialogResult.OK) { pdoc.Print(); } } }
private void UCDictionaryManager_Load(object sender, EventArgs e) { base.RoleButtonStstus(this.Name); DataGridViewEx.SetDataGridViewStyle(dgvDicList); DataSources.BindComBoxDataEnum(cobDataSources, typeof(DataSources.EnumDataSources), true);//数据来源 base.btnCopy.Visible = false; base.btnStatus.Visible = false; base.btnAdd.Visible = false; base.btnEdit.Visible = false; base.btnSave.Visible = false; base.btnCancel.Visible = false; base.btnDelete.Visible = false; base.SetBtnStatus(WindowStatus.View); base.ExportEvent += new ClickHandler(UCDictionaryManager_ExportEvent); base.ViewEvent += new ClickHandler(UCDictionaryManager_ViewEvent); base.PrintEvent += new ClickHandler(UCDictionaryManager_PrintEvent); dtpStart.Value = ""; dtpEnd.Value = ""; btnSearch_Click(null, null); List<string> listNotPrint = new List<string>(); PaperSize paperSize = new PaperSize(); paperSize.Width = 360; paperSize.Height = 210; businessPrint = new BusinessPrint(dgvDicList, "v_dictionaries", "字典码表", paperSize, listNotPrint); SetQuick(); UIAssistants.SetButtonStyle4QueryAndClear(btnSearch, btnClear, true); //设置查询按钮和清除按钮样式 }
BusinessPrint businessPrint;//业务打印功能 #endregion #region 初始化窗体 /// <summary> 初始化窗体 /// </summary> public UCPurchasePlanOrderManagView() { InitializeComponent(); //base.SetBaseButtonStatus(); //base.SetButtonVisiableManagerSearch(); string[] NotReadOnlyColumnsName = new string[] { "colCheck" }; CommonFuncCall.SetColumnReadOnly(gvPurchasePlanOrderList, NotReadOnlyColumnsName); //禁止列表自增列 gvPurchasePlanOrderList.AutoGenerateColumns = false; dateTimeStart.Value = DateTime.Now.AddDays(-DateTime.Now.Day + 1); dateTimeEnd.Value = DateTime.Now; string com_id = GlobalStaticObj.CurrUserCom_Id;//公司ID CommonFuncCall.BindDepartment(ddlDepartment, com_id, "全部"); CommonFuncCall.BindHandle(ddlResponsiblePerson, "", "全部"); CommonFuncCall.BindPurchasePlanFinishStatus(ddlFinishStatus, true); BindgvPurchasePlanOrderList(); gvPurchasePlanOrderList.CellMouseClick += new DataGridViewCellMouseEventHandler(gvPurchasePlanOrderList_CellMouseClick); base.ExportEvent += new ClickHandler(UCPurchasePlanOrderManagView_ExportEvent); base.ViewEvent += new ClickHandler(UCPurchasePlanOrderManagView_ViewEvent); base.PrintEvent += new ClickHandler(UCPurchasePlanOrderManagView_PrintEvent); base.SetEvent += new ClickHandler(UCPurchasePlanOrderManagView_SetEvent); #region 预览、打印设置 string printObject = "tb_parts_purchase_plan_s"; string printTitle = "采购计划单查询"; List<string> listNotPrint = new List<string>(); listNotPrint.Add(plan_id.Name); PaperSize paperSize = new PaperSize(); paperSize.Width = 297; paperSize.Height = 210; businessPrint = new BusinessPrint(gvPurchasePlanOrderList, printObject, printTitle, paperSize, listNotPrint); #endregion }
BusinessPrint businessPrint;//业务打印功能 #endregion #region 初始化窗体 public UCFMaterialReturnManager() { InitializeComponent(); BindOrderStatus(); // BindWarehouseWay(); base.ViewEvent += new ClickHandler(UCFMaterialReturnManager_ViewEvent); base.DeleteEvent += new ClickHandler(UCFMaterialReturnManager_DeleteEvent); base.EditEvent += new ClickHandler(UCFMaterialReturnManager_EditEvent); base.VerifyEvent += new ClickHandler(UCFMaterialReturnManager_VerifyEvent); base.SubmitEvent += new ClickHandler(UCFMaterialReturnManager_SubmitEvent); base.ImportEvent += new ClickHandler(UCFMaterialReturnManager_ImportEvent); base.PrintEvent += new ClickHandler(UCFMaterialReturnManager_PrintEvent); base.ExportEvent += new ClickHandler(UCFMaterialReturnManager_ExportEvent); UIAssistants.SetButtonStyle4QueryAndClear(btnQuery, btnClear); //设置查询按钮和清除按钮样式 base.SetEvent += new ClickHandler(UCFMaterialReturnManager_SetEvent); SetQuick(); base.SetContentMenuScrip(dgvRData); #region 预览、打印设置 string printObject = "tb_maintain_refund_material"; string printTitle = "领料退货单"; List<string> listNotPrint = new List<string>(); listNotPrint.Add(refund_id.Name); //listNotPrint.Add(v_brand.Name); PaperSize paperSize = new PaperSize(); paperSize.Width = 297; paperSize.Height = 210; businessPrint = new BusinessPrint(dgvRData, printObject, printTitle, paperSize, listNotPrint); #endregion }
/// <summary> /// 数据打印 /// </summary> /// <param name="printData"></param> public virtual void InvoicePrint(PrintDataClass printData) { PrintDocument document = new PrintDocument(); //this.PrintData = printData; Margins margins = new Margins(this.DanToPex(0.5M), this.DanToPex(0.5M), this.DanToPex(0.5M), this.DanToPex(0.5M)); document.DefaultPageSettings.Margins = margins; PaperSize size = new PaperSize("First custom size", this.DanToPex(PageSizeW), this.DanToPex(PageSizeH)); document.DefaultPageSettings.PaperSize = size; document.PrintController = new StandardPrintController(); document.PrintPage += new PrintPageEventHandler(this.pd_PrintPage); try { document.Print(); LogHelper.WriteLog("过磅编号为:" + GetTextDate() + "。数据打印成功!"); } catch (Exception e) { document.PrintController.OnEndPrint(document, new PrintEventArgs()); LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "打印失败!", e); } finally { this.printData = null; } }
BusinessPrint businessPrint;//业务打印功能 #endregion #region 初始化 public ReserveOrder() { InitializeComponent(); CommonCtrl.BindComboBoxByDictionarr(cobPayType, "sys_repair_pay_methods", true);//绑定维修付费方式 this.BindOrderStatus(); UIAssistants.SetButtonStyle4QueryAndClear(btnQuery, btnClear); //设置查询按钮和清除按钮样式 base.AddEvent += new ClickHandler(ReserveOrder_AddEvent); base.CopyEvent += new ClickHandler(ReserveOrder_CopyEvent); base.EditEvent += new ClickHandler(ReserveOrder_EditEvent); base.DeleteEvent += new ClickHandler(ReserveOrder_DeleteEvent); base.ViewEvent += new ClickHandler(ReserveOrder_ViewEvent); base.SubmitEvent += new ClickHandler(ReserveOrder_SubmitEvent); base.VerifyEvent += new ClickHandler(ReserveOrder_VerifyEvent); base.PrintEvent += new ClickHandler(ReserveOrder_PrintEvent); base.SetEvent += new ClickHandler(ReserveOrder_SetEvent); SetQuick(); base.SetContentMenuScrip(dgvRData); #region 预览、打印设置 string printObject = "tb_maintain_reservation"; string printTitle = "预约单"; List<string> listNotPrint = new List<string>(); listNotPrint.Add(reserv_id.Name); //listNotPrint.Add(v_brand.Name); PaperSize paperSize = new PaperSize(); paperSize.Width = 297; paperSize.Height = 210; businessPrint = new BusinessPrint(dgvRData , printObject, printTitle, paperSize, listNotPrint); #endregion }
// #region 事件处理相关... // private DrawObjEventHandler _BeforDrawObject; // public event DrawObjEventHandler BeforDrawObject { // add { // _BeforDrawObject += value; // } // remove { // _BeforDrawObject -= value; // } // // } // private void FireBeforDrawObject(DrawObjEventArgs e) { // if (mBeforDrawObject != null) { // // 调用相应的委托代理 // mBeforDrawObject(this, e); // } // } // #endregion 事件处理相关... public DrawReport(object pDs, DIYReport.ReportModel.RptReport pDataReport) { _RptData = pDs; DIYReport.UserDIY.DesignEnviroment.DataSource = pDs; _DataReport = pDataReport; _Rows = DIYReport.GroupAndSort.GroupDataProcess.SortData(pDs, pDataReport); _RptInfo = new ReportDrawInfo(pDataReport); _FooterExpress = DIYReport.Express.ExpressValueList.GetFooterExpress(pDataReport); _BottomExpress = DIYReport.Express.ExpressValueList.GetBottomExpress(pDataReport); _DocSize = _DataReport.PaperSize; _DocMargin = _DataReport.Margins; //初始化页页数 DIYReport.Express.ExSpecial._Page = 1; DIYReport.Express.ExSpecial._PageCount = 1; _DrawDetailInfo = new DrawDetailInfo(pDataReport); _GroupFoots = new Stack(); _GroupHeads = new Queue(); float mergeHeight = _DataReport.SectionList.GetExceptDetailHeight(); int rHeight = _DataReport.IsLandscape? _DocSize.Width : _DocSize.Height; REAL_DETAIL_HEIGHT = rHeight - Convert.ToInt32(mergeHeight) - _DocMargin.Top - _DocMargin.Bottom; int rWidth = _DataReport.IsLandscape? _DocSize.Height : _DocSize.Width; REAL_PAGE_WIDTH = rWidth - _DocMargin.Left - _DocMargin.Right; DIYReport.Express.ExSpecial._RowOrderNO = 0; }
BusinessPrint businessPrint;//业务打印功能 #region 窗体初始化 /// <summary> 窗体初始化 /// </summary> public UCPurchaseBillManang() { InitializeComponent(); dateTimeStart.Value = DateTime.Now.AddDays(-DateTime.Now.Day + 1); dateTimeEnd.Value = DateTime.Now; base.AddEvent += new ClickHandler(UCPurchaseBillManang_AddEvent); base.EditEvent += new ClickHandler(UCPurchaseBillManang_EditEvent); base.CopyEvent += new ClickHandler(UCPurchaseBillManang_CopyEvent); base.DeleteEvent += new ClickHandler(UCPurchaseBillManang_DeleteEvent); base.VerifyEvent += new ClickHandler(UCPurchaseBillManang_VerifyEvent); base.SubmitEvent += new ClickHandler(UCPurchaseBillManang_SubmitEvent); base.ExportEvent += new ClickHandler(UCPurchaseBillManang_ExportEvent); base.ViewEvent += new ClickHandler(UCPurchaseBillManang_ViewEvent); base.PrintEvent += new ClickHandler(UCPurchaseBillManang_PrintEvent); base.SetEvent += new ClickHandler(UCPurchaseBillManang_SetEvent); #region 预览、打印设置 string printObject = "tb_parts_purchase_billing"; string printTitle = "采购开单"; List<string> listNotPrint = new List<string>(); listNotPrint.Add(purchase_billing_id.Name); PaperSize paperSize = new PaperSize(); paperSize.Width = 297; paperSize.Height = 210; businessPrint = new BusinessPrint(gvPurchaseOrderList, printObject, printTitle, paperSize, listNotPrint); #endregion }
public Reportes() { InitializeComponent(); System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings(); pg.Margins.Top = 0; pg.Margins.Bottom = 0; pg.Margins.Left = 0; pg.Margins.Right = 0; System.Drawing.Printing.PaperSize size = new System.Drawing.Printing.PaperSize(); size.RawKind = (int)PaperKind.B5; System.Drawing.Printing.PageSettings orient = new System.Drawing.Printing.PageSettings(); pg.PaperSize = size; Reporte.SetPageSettings(pg); this.Reporte.RefreshReport(); Reporte.Reset(); var suc = (from sc in sb.sucursal select sc.sucursal1).ToList(); foreach (var item in suc) { listBox.Items.Add(item); } var car = (from cr in sb.cargo select cr.cargo1).ToList(); cbCargo.Items.Add("<<ninguno>>"); foreach (var item in car) { cbCargo.Items.Add(item); } cbCargo.SelectedIndex = 0; }
private void Payments_Full_Report_Load(object sender, EventArgs e) { ReportDataSource ds = new ReportDataSource(); ds.Name = "DataSet1"; ds.Value = GeneratePaymentData(); this.reportViewer1.ProcessingMode = ProcessingMode.Local; this.reportViewer1.LocalReport.ReportPath = @"Report5.rdlc"; this.reportViewer1.LocalReport.DataSources.Add(ds); System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings(); pg.Margins.Top = 0; pg.Landscape = true; pg.Margins.Bottom = 0; pg.Margins.Left = 50; pg.Margins.Right = 0; System.Drawing.Printing.PaperSize size = new PaperSize(); size.RawKind = (int)PaperKind.A4; pg.PaperSize = size; pg.Landscape = true; this.reportViewer1.SetPageSettings(pg); this.reportViewer1.RefreshReport(); }
BusinessPrint businessPrint;//业务打印功能 #endregion #region 初始化窗体 public UCDispatchManager() { InitializeComponent(); CommonCtrl.BindComboBoxByDictionarr(cobPayType, "sys_repair_pay_methods", true);//绑定维修付费方式 BindOrderStatus(); SetTopbuttonShow(); UIAssistants.SetButtonStyle4QueryAndClear(btnQuery, btnClear); //设置查询按钮和清除按钮样式 base.ViewEvent += new ClickHandler(UCDispatchManager_ViewEvent); base.Delete += new ClickHandler(UCDispatchManager_Delete); base.QCEvent += new ClickHandler(UCDispatchManager_QCEvent); base.BalanceEvent += new ClickHandler(UCDispatchManager_BalanceEvent); base.PrintEvent += new ClickHandler(UCDispatchManager_PrintEvent); base.SetEvent += new ClickHandler(UCDispatchManager_SetEvent); SetQuick(); #region 预览、打印设置 string printObject = "tb_maintain_info_dd"; string printTitle = "维修调度单"; List<string> listNotPrint = new List<string>(); listNotPrint.Add(maintain_id.Name); //listNotPrint.Add(v_brand.Name); PaperSize paperSize = new PaperSize(); paperSize.Width = 297; paperSize.Height = 210; businessPrint = new BusinessPrint(dgvRData, printObject, printTitle, paperSize, listNotPrint); #endregion }
BusinessPrint businessPrint;//业务打印功能 #endregion #region 初始化窗体 public UCRepairRescueManager() { InitializeComponent(); BindOrderStatus(); CommonCtrl.BindComboBoxByDictionarr(cobRescueType, "sys_rescue_type", true);//救援类型 UIAssistants.SetButtonStyle4QueryAndClear(btnQuery, btnClear); //设置查询按钮和清除按钮样式 base.AddEvent += new ClickHandler(UCRepairRescueManager_AddEvent); base.CopyEvent += new ClickHandler(UCRepairRescueManager_CopyEvent); base.EditEvent += new ClickHandler(UCRepairRescueManager_EditEvent); base.DeleteEvent += new ClickHandler(UCRepairRescueManager_DeleteEvent); base.ViewEvent += new ClickHandler(UCRepairRescueManager_ViewEvent); base.VerifyEvent += new ClickHandler(UCRepairRescueManager_VerifyEvent); base.BalanceEvent += new ClickHandler(UCRepairRescueManager_BalanceEvent); base.PrintEvent += new ClickHandler(UCRepairRescueManager_PrintEvent); base.SetEvent += new ClickHandler(UCRepairRescueManager_SetEvent); SetQuick(); base.SetContentMenuScrip(dgvRData); #region 预览、打印设置 string printObject = "tb_maintain_rescue_info"; string printTitle = "救援单"; List<string> listNotPrint = new List<string>(); listNotPrint.Add(rescue_id.Name); PaperSize paperSize = new PaperSize(); paperSize.Width = 297; paperSize.Height = 210; businessPrint = new BusinessPrint(dgvRData, printObject, printTitle, paperSize, listNotPrint); #endregion }
public UCFeedbackManager() { InitializeComponent(); UIAssistants.SetButtonStyle4QueryAndClear(btnQuery, btnClear, true); //设置查询按钮和清除按钮样式 DataGridViewEx.SetDataGridViewStyle(dgvQData, drtxt_status); //设置数据表格样式,并将最后一列填充其余空白 Init(); Load += (sender, args) => UIAssistants.SetDataGridViewCheckColumn(dgvQData, drchk_check); SetContentMenuScrip(dgvQData); #region 预览、打印设置 string printObject = "tb_CustomerSer_Feedback"; string printTitle = "信息反馈"; List<string> listNotPrint = new List<string>(); listNotPrint.Add(drtxt_Feedback_id.Name); //listNotPrint.Add(v_brand.Name); PaperSize paperSize = new PaperSize(); paperSize.Width = 297; paperSize.Height = 210; businessPrint = new BusinessPrint(dgvQData, printObject, printTitle, paperSize, listNotPrint); #endregion }
BusinessPrint businessPrint;//业务打印功能 #region 初始化窗体 public UCSalePlanManager() { InitializeComponent(); base.AddEvent += new ClickHandler(UCSalePlanManager_AddEvent); base.CopyEvent += new ClickHandler(UCSalePlanManager_CopyEvent); base.EditEvent += new ClickHandler(UCSalePlanManager_EditEvent); base.DeleteEvent += new ClickHandler(UCSalePlanManager_DeleteEvent); base.VerifyEvent += new ClickHandler(UCSalePlanManager_VerifyEvent); base.SubmitEvent += new ClickHandler(UCSalePlanManager_SubmitEvent); base.ExportEvent += new ClickHandler(UCSalePlanManager_ExportEvent); base.ViewEvent += new ClickHandler(UCSalePlanManager_ViewEvent); base.PrintEvent += new ClickHandler(UCSalePlanManager_PrintEvent); base.SetEvent += new ClickHandler(UCSalePlanManager_SetEvent); #region 预览、打印设置 string printObject = "tb_parts_sale_plan"; string printTitle = "销售计划单"; List<string> listNotPrint = new List<string>(); listNotPrint.Add(sale_plan_id.Name); PaperSize paperSize = new PaperSize(); paperSize.Width = 297; paperSize.Height = 210; businessPrint = new BusinessPrint(gvSalePlanList, printObject, printTitle, paperSize, listNotPrint); #endregion }
BusinessPrint businessPrint;//业务打印功能 #endregion public UCAccountVerificationManage() { InitializeComponent(); this.AddEvent += new ClickHandler(UCAccountVerificationManage_AddEvent); this.EditEvent += new ClickHandler(UCAccountVerificationManage_EditEvent); this.CopyEvent += new ClickHandler(UCAccountVerificationManage_CopyEvent); this.ViewEvent += new ClickHandler(UCAccountVerificationManage_ViewEvent); this.DeleteEvent += new ClickHandler(UCAccountVerificationManage_DeleteEvent); this.VerifyEvent += new ClickHandler(UCAccountVerificationManage_VerifyEvent); this.SubmitEvent += new ClickHandler(UCAccountVerificationManage_SubmitEvent); this.PrintEvent += new ClickHandler(UCAccountVerificationManage_PrintEvent); this.ExportEvent += new ClickHandler(UCAccountVerificationManage_ExportEvent); dgvVerification.ReadOnly = false; dgvVerification.HeadCheckChanged += new DataGridViewEx.DelegateOnClick(dgvVerification_HeadCheckChanged); foreach (DataGridViewColumn dgvc in dgvVerification.Columns) { if (dgvc.Name == colChk.Name) { continue; } dgvc.ReadOnly = true; } List<string> listNotPrint = new List<string>(); listNotPrint.Add(colOrgId.Name); listNotPrint.Add(colHandle.Name); PaperSize paperSize = new PaperSize(); paperSize.Width = 297; paperSize.Height = 210; businessPrint = new BusinessPrint(dgvVerification, "tb_account_verification", "往来核销", paperSize, listNotPrint); }
public override void Execute() { printDocument = new PrintDocument(); printDocument.OriginAtMargins = true; printDocument.BeginPrint += new PrintEventHandler(printDocument_BeginPrint); printDocument.PrintPage += new PrintPageEventHandler(printDocument_PrintPage); Dictionary<String, Object> paperSettings = Printing.getPaperSettings(grtArguments); printDocument.DefaultPageSettings.Landscape = (string)paperSettings["orientation"] == "landscape"; // Sizes must be given in inch * 100 (sigh). int paperWidth = (int)Math.Round((double)paperSettings["width"] / 0.254); int paperHeight = (int)Math.Round((double)paperSettings["height"] / 0.254); PaperSize paperSize = new PaperSize("Ignored anyway", paperWidth, paperHeight); if ((bool)paperSettings["marginsSet"]) printDocument.DefaultPageSettings.Margins = new Margins((int)paperSettings["marginLeft"], (int)paperSettings["marginRight"], (int)paperSettings["marginTop"], (int)paperSettings["marginBottom"]); System.Windows.Forms.PrintPreviewDialog preview = new System.Windows.Forms.PrintPreviewDialog(); preview.Document = printDocument; preview.UseAntiAlias = true; preview.ShowDialog(); }
public LocalReportPrinter(string reportFullPath, PaperSize paperSize = null) { _reportFullPath = Application.StartupPath + @"\" + reportFullPath; _report = new LocalReport { ReportPath = _reportFullPath }; _paperSize = paperSize ?? _report.GetDefaultPageSettings().PaperSize; _streams = new List<Stream>(); }
public void Print() { //打印 if (string.IsNullOrEmpty(_print_doc.PrinterSettings.PrinterName)) { _print_doc.PrinterSettings.PrinterName = new System.Drawing.Printing.PrintDocument().PrinterSettings.PrinterName; } //_print_doc.PrinterSettings.PrinterName = "Zebra 105SL"; // "Microsoft XPS Document Writer"; // System.Drawing.Printing.Margins margins = new System.Drawing.Printing.Margins(0, 0, 0, 0); _print_doc.DefaultPageSettings.Margins = margins; // 设置纸张 PaperSize paperSize = new PaperSize(); switch (_lable.Type) { case LableType.BIG: case LableType.BIG1: case LableType.PIPE: case LableType.PIPE2: paperSize.Height = 394; paperSize.Width = 285; paperSize.PaperName = "大标牌"; _print_doc.DefaultPageSettings.PaperSize = paperSize; break; case LableType.LITTLE: paperSize.Height = 217; paperSize.Width = 264; paperSize.PaperName = "小标牌"; _print_doc.DefaultPageSettings.PaperSize = paperSize; break; default: break; } _print_doc.DefaultPageSettings.PrinterSettings.Copies = (short)_copies; _print_doc.Print(); }
/// <summary> /// 初始化窗体 /// </summary> public UCYTManager() { InitializeComponent(); base.AddEvent += new ClickHandler(UCYTManager_AddEvent); base.CopyEvent += new ClickHandler(UCYTManager_CopyEvent); base.EditEvent += new ClickHandler(UCYTManager_EditEvent); base.DeleteEvent += new ClickHandler(UCYTManager_DeleteEvent); base.VerifyEvent += new ClickHandler(UCYTManager_VerifyEvent); base.SubmitEvent += new ClickHandler(UCYTManager_SubmitEvent); base.ExportEvent += new ClickHandler(UCYTManager_ExportEvent); base.ViewEvent += new ClickHandler(UCYTManager_ViewEvent); base.PrintEvent += new ClickHandler(UCYTManager_PrintEvent); base.SetEvent += new ClickHandler(UCYTManager_SetEvent); #region 预览、打印设置 string printObject = "tb_parts_purchase_order_ytcg"; string printTitle = "宇通采购订单"; List<string> listNotPrint = new List<string>(); listNotPrint.Add(purchase_order_yt_id.Name); listNotPrint.Add(viewfile.Name); PaperSize paperSize = new PaperSize(); paperSize.Width = 297; paperSize.Height = 210; businessPrint = new BusinessPrint(gvYTPurchaseOrderList, printObject, printTitle, paperSize, listNotPrint); #endregion }
BusinessPrint businessPrint;//业务打印功能 #endregion #region 初始化窗体 public UCOldPartsPalautusManager() { InitializeComponent(); BindOrderStatus(); UIAssistants.SetButtonStyle4QueryAndClear(btnQuery, btnClear); //设置查询按钮和清除按钮样式 BindStatusYT();// 绑定宇通旧件回收单状态 base.AddEvent += new ClickHandler(UCOldPartsPalautusManager_AddEvent); base.EditEvent += new ClickHandler(UCOldPartsPalautusManager_EditEvent); base.DeleteEvent += new ClickHandler(UCOldPartsPalautusManager_DeleteEvent); base.SubmitEvent += new ClickHandler(UCOldPartsPalautusManager_SubmitEvent); base.VerifyEvent += new ClickHandler(UCOldPartsPalautusManager_VerifyEvent); base.ViewEvent += new ClickHandler(UCOldPartsPalautusManager_ViewEvent); base.ConfirmEvent += new ClickHandler(UCOldPartsPalautusManager_ConfirmEvent); base.PrintEvent += new ClickHandler(UCOldPartsPalautusManager_PrintEvent); base.SetEvent += new ClickHandler(UCOldPartsPalautusManager_SetEvent); #region 预览、打印设置 string printObject = "tb_maintain_oldpart_recycle"; string printTitle = "宇通旧件返厂单"; List<string> listNotPrint = new List<string>(); listNotPrint.Add(return_id.Name); //listNotPrint.Add(v_brand.Name); PaperSize paperSize = new PaperSize(); paperSize.Width = 297; paperSize.Height = 210; businessPrint = new BusinessPrint(dgvRData, printObject, printTitle, paperSize, listNotPrint); #endregion }
private void printPaper() { DGVPrinterHelper.DGVPrinter printer = new DGVPrinterHelper.DGVPrinter(); printer.Title = "Quán 193"; printer.SubTitle = "Bàn " + Num; printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip; System.Drawing.Printing.PaperSize paperSize = new System.Drawing.Printing.PaperSize("Envelop", 4000, 3000); paperSize.RawKind = (int)PaperKind.Custom; DateTime dateTime = DateTime.Now; string datrStr = dateTime.ToString("dd-MM _ hh-mm"); Console.WriteLine("Print something: "); //printer.PrintSettings.PrintFileName = Num+ "_" + datrStr + ".pdf"; Console.ReadLine(); printer.PorportionalColumns = true; printer.Footer = "193 Ung Văn Khiêm phường 25 quận Bình Thạnh"; printer.FooterSpacing = 15; printer.printDocument.DocumentName = "Bàn_" + Num + "_" + datrStr + ".pdf"; printer.PrintDataGridView(dataGridView1); //Console.WriteLine("Print file name: {0}", printer.PrintSettings.PrintFileName); this.Close(); }
void comboBox_Papers_DrawItem(object sender, DrawItemEventArgs e) { ComboBox comboBox = sender as ComboBox; if (e.Index == -1 || e.Index >= comboBox.Items.Count) { return; } e.DrawBackground(); if ((e.State & DrawItemState.Focus) != 0) { e.DrawFocusRectangle(); } Brush b = null; try { System.Drawing.Printing.PaperSize size = comboBox.Items[e.Index] as System.Drawing.Printing.PaperSize; double Width = Convert.ToDouble(PrinterUnitConvert.Convert(size.Width * 1.0, PrinterUnit.Display, PrinterUnit.TenthsOfAMillimeter) / 100.0); double Height = Convert.ToDouble(PrinterUnitConvert.Convert(size.Height * 1.0, PrinterUnit.Display, PrinterUnit.TenthsOfAMillimeter) / 100.0); b = new SolidBrush(e.ForeColor); e.Graphics.DrawString(string.Format("{0} [{1}ÀåÃסÁ{2}ÀåÃ×]", size.PaperName, Width, Height), new Font(comboBox.Items[e.Index].ToString(), 10F), b, e.Bounds); } finally { if (b != null) { b.Dispose(); } b = null; } }
public override void Execute() { printDocument = new PrintDocument(); printDocument.OriginAtMargins = true; printDocument.BeginPrint += new PrintEventHandler(printDocument_BeginPrint); printDocument.PrintPage += new PrintPageEventHandler(printDocument_PrintPage); Dictionary<String, Object> paperSettings = Printing.getPaperSettings(grtArguments); printDocument.DefaultPageSettings.Landscape = (string)paperSettings["orientation"] == "landscape"; // Sizes must be given in inch * 100 (sigh). int paperWidth = (int)Math.Round((double)paperSettings["width"] / 0.254); int paperHeight = (int)Math.Round((double)paperSettings["height"] / 0.254); PaperSize paperSize = new PaperSize("Doesn't matter", paperWidth, paperHeight); printDocument.DefaultPageSettings.PaperSize = paperSize; if ((bool)paperSettings["marginsSet"]) printDocument.DefaultPageSettings.Margins = new Margins((int)paperSettings["marginLeft"], (int)paperSettings["marginRight"], (int)paperSettings["marginTop"], (int)paperSettings["marginBottom"]); printDialog = new System.Windows.Forms.PrintDialog(); printDialog.Document = printDocument; printDialog.AllowPrintToFile = true; pageNumber = 0; pageCount = -1; if (printDialog.ShowDialog() == DialogResult.OK) { printDocument.Print(); } }
private static void PrintPage(object o, PrintPageEventArgs e) { float height = 0; //header String drawString = _1; Font drawFont = new Font("MS Gothic", 14, FontStyle.Regular); SolidBrush drawBrush = new SolidBrush(Color.Black); StringFormat drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, 0, 0, drawFormat); SizeF stringSize = new SizeF(); stringSize = e.Graphics.MeasureString(_1, drawFont); height = float.Parse(stringSize.Height.ToString()) + height; //stavke drawString = _2; drawFont = new Font("MS Gothic", 14, FontStyle.Bold); float y = height; float x = 0.0F; drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); stringSize = e.Graphics.MeasureString(_2, drawFont); height = float.Parse(stringSize.Height.ToString()) + height; if (e.HasMorePages) { e.HasMorePages = false; } if (height > e.PageSettings.PaperSize.Height) { PaperSize psNew = new System.Drawing.Printing.PaperSize("Racun", e.PageSettings.PrinterSettings.DefaultPageSettings.PaperSize.Width, (int)height + 1); Size sSize = new Size(psNew.Width, psNew.Height); e.PageSettings.PrinterSettings.DefaultPageSettings.PaperSize = psNew; e.PageSettings.PrinterSettings.DefaultPageSettings.Bounds.Inflate(sSize); e.PageSettings.PrinterSettings.DefaultPageSettings.PrintableArea.Inflate(sSize); e.PageSettings.PrinterSettings.DefaultPageSettings.PrinterSettings.DefaultPageSettings.PrintableArea.Inflate(sSize); e.PageSettings.PaperSize = psNew; e.PageSettings.Bounds.Inflate(sSize); e.PageBounds.Inflate(sSize); e.PageSettings.PrintableArea.Inflate(sSize); e.HasMorePages = true; e.Graphics.Clear(Color.White); e.Graphics.ResetClip(); e.Graphics.Clip.MakeEmpty(); //e.Graphics.Dispose(); //e.Graphics. } }
private static int TotalWidth; // Summation of Columns widths #endregion Fields #region Methods public static void Print_DataGridView(DataGridView dgv1) { PrintPreviewDialog ppvw; try { // Getting DataGridView object to print dgv = dgv1; // Getting all Coulmns Names in the DataGridView AvailableColumns.Clear(); foreach (DataGridViewColumn c in dgv.Columns) { if (!c.Visible) continue; AvailableColumns.Add(c.HeaderText); } // Showing the PrintOption Form PrintOptions dlg = new PrintOptions(AvailableColumns); if (dlg.ShowDialog() != DialogResult.OK) return; PrintAllRows = dlg.PrintAllRows; FitToPageWidth = dlg.FitToPageWidth; SelectedColumns = dlg.GetSelectedColumns(); RowsPerPage = 0; ppvw = new PrintPreviewDialog(); ppvw.Document = printDoc; // Showing the Print Preview Page printDoc.BeginPrint +=new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint); printDoc.PrintPage +=new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage); printDoc.DefaultPageSettings.Landscape = true; PaperSize paperSize = new PaperSize("Letter", 850, 1100); paperSize.RawKind = (int)PaperKind.Custom; printDoc.DefaultPageSettings.PaperSize = paperSize; if (ppvw.ShowDialog() != DialogResult.OK) { printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint); printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage); return; } // Printing the Documnet printDoc.DefaultPageSettings.Landscape = true; printDoc.DefaultPageSettings.PaperSize = paperSize; printDoc.Print(); printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint); printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { } }
public PaperSize getPaperSize(Image myImage, int iRollWigth=80) { PaperSize p=new PaperSize(); p.Width = mmToInch(iRollWigth); double d = (double)p.Width * ((double)myImage.Height / (double)myImage.Width); p.Height =(int) d; return p; }
/// <summary> /// 窗体加载方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UCWorkingTimeManager_Load(object sender, EventArgs e) { PaperSize printsize = new PaperSize("dgv",gvWorkList.Size.Width/3, gvWorkList.Size.Height/2); businessPrint = new BusinessPrint(gvWorkList, "tb_workhours", "工时档案", printsize, new List<string>()); gvWorkList.ReadOnly = false; base.SetBtnStatus(WindowStatus.View); UIAssistants.SetButtonStyle4QueryAndClear(btnSearch, btnClear); //设置查询按钮和清除按钮样式 }
public CustomBaseDoc() { int width = (int)(PaperWidth / 2.54 * 100 + 0.5); int height = (int)(PaperHeight / 2.54 * 100 + 0.5); _paperSize = new System.Drawing.Printing.PaperSize(ApplicationConfiguration.PrintPageName, width, height); // btnMultiPrint.Visible = true; }
private void cboPrinters_SelectedIndexChanged(object sender, EventArgs e) { int iMaxPaperHeight = 0; int iMaxPaperWidth = 0; System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument(); System.Drawing.Printing.PaperSize pkSize = new System.Drawing.Printing.PaperSize(); this.cboMapSize.Items.Clear(); this.cboMapSize.Enabled = false; pd.PrinterSettings.PrinterName = this.cboPrinters.SelectedItem.ToString(); foreach (PaperSize psize in pd.PrinterSettings.PaperSizes) { if (psize.Width > iMaxPaperWidth) { iMaxPaperWidth = psize.Width; } if (psize.Height > iMaxPaperHeight) { iMaxPaperHeight = psize.Height; } } if ((iMaxPaperWidth * .01) > 8.5) { if ((iMaxPaperWidth * .01) > 11.69) { if ((iMaxPaperWidth * .01) > 17) { this.cboMapSize.Items.Add("8.5 x 11"); this.cboMapSize.Items.Add("11 x 17"); this.cboMapSize.Items.Add("17 x 22"); this.cboMapSize.Items.Add("34 x 44"); } else { this.cboMapSize.Items.Add("8.5 x 11"); this.cboMapSize.Items.Add("11 x 17"); this.cboMapSize.Items.Add("17 x 22"); } } else { this.cboMapSize.Items.Add("8.5 x 11"); this.cboMapSize.Items.Add("11 x 17"); } } else { this.cboMapSize.Items.Add("8.5 x 11"); } this.cboMapSize.Enabled = true; this.cboMapSize.SelectedIndex = 0; // this.cboMapSize.Items.Count - 1; }
private void PrintPage(object o, PrintPageEventArgs e) { float height = 0; System.Drawing.Text.PrivateFontCollection privateFonts = new PrivateFontCollection(); privateFonts.AddFontFile("Slike/msgothic.ttc"); System.Drawing.Font font = new Font(privateFonts.Families[0], 10); //header string drawString = tekst; Font drawFont = font; SolidBrush drawBrush = new SolidBrush(Color.Black); StringFormat drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, 0, 0, drawFormat); SizeF stringSize = new SizeF(); stringSize = e.Graphics.MeasureString(tekst, drawFont); drawFont = font; float y = 0.0F; float x = 0.0F; e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); height = float.Parse(stringSize.Height.ToString()) + height; if (e.HasMorePages) { e.HasMorePages = false; } if (height > e.PageSettings.PaperSize.Height) { PaperSize psNew = new System.Drawing.Printing.PaperSize("Racun", e.PageSettings.PrinterSettings.DefaultPageSettings.PaperSize.Width, (int)height + 1); Size sSize = new Size(psNew.Width, psNew.Height); e.PageSettings.PrinterSettings.DefaultPageSettings.PaperSize = psNew; e.PageSettings.PrinterSettings.DefaultPageSettings.Bounds.Inflate(sSize); e.PageSettings.PrinterSettings.DefaultPageSettings.PrintableArea.Inflate(sSize); e.PageSettings.PrinterSettings.DefaultPageSettings.PrinterSettings.DefaultPageSettings.PrintableArea.Inflate(sSize); e.PageSettings.PaperSize = psNew; e.PageSettings.Bounds.Inflate(sSize); e.PageBounds.Inflate(sSize); e.PageSettings.PrintableArea.Inflate(sSize); e.HasMorePages = true; e.Graphics.Clear(Color.White); e.Graphics.ResetClip(); e.Graphics.Clip.MakeEmpty(); //e.Graphics.Dispose(); //e.Graphics. } }
// used by PrinterSettings.DefaultPageSettings internal PageSettings(PrinterSettings printerSettings, bool color, bool landscape, PaperSize paperSize, PaperSource paperSource, PrinterResolution printerResolution) { PrinterSettings = printerSettings; this.color = color; this.landscape = landscape; this.paperSize = paperSize; this.paperSource = paperSource; this.printerResolution = printerResolution; }
/// <summary> /// Clic en el botón de imprimir. /// </summary private void btnImprimir_Click(object sender, EventArgs e) { pdOpcionesImpresion.PrinterSettings.PrinterName = Properties.Settings.Default.ImpresoraManifiestos; if (pdOpcionesImpresion.ShowDialog() == DialogResult.OK) { string nombre_impresora = pdOpcionesImpresion.PrinterSettings.PrinterName; Properties.Settings.Default.ImpresoraManifiestos = nombre_impresora; Properties.Settings.Default.Save(); if (cboEsquema.SelectedItem == null) { return; } else { _esquema = (EsquemaManifiesto)cboEsquema.SelectedItem; } PrinterSettings configuracion = new PrinterSettings(); configuracion.PrinterName = nombre_impresora; pdManifiesto.PrinterSettings = configuracion; PaperSize tamano = new System.Drawing.Printing.PaperSize(); tamano.RawKind = (int)(int)System.Drawing.Printing.PaperKind.Custom; tamano.Height = (int)(_esquema.Alto * 100 / (decimal)2.54); tamano.Width = (int)(_esquema.Ancho * 100 / (decimal)2.54); PageSettings configuracion_pagina = new PageSettings(configuracion); configuracion_pagina.Margins.Left = 0; configuracion_pagina.Margins.Top = 0; configuracion_pagina.Margins.Right = 0; configuracion_pagina.Margins.Bottom = 0; configuracion_pagina.PaperSize = tamano; pdManifiesto.DefaultPageSettings = configuracion_pagina; if (_impresion_carga && chkImprimirManifiesto.Checked && !txtMarchamo.Text.Equals(string.Empty)) { pdManifiesto.Print(); } if (_impresion_full && chkImprimirManifiestoFull.Checked && !txtMarchamoFull.Text.Equals(string.Empty)) { _siguiente_full = true; pdManifiesto.Print(); } } }
private void printDocument_BeginPrint(object sender, System.Drawing.Printing.PrintEventArgs e) { string printerName = this.rdoYes.Checked ? "成人腕带" : "儿童腕带"; System.Drawing.Printing.PaperSize ps = this.rdoYes.Checked ? (new System.Drawing.Printing.PaperSize(printerName, 138, 1003)) : (new System.Drawing.Printing.PaperSize(printerName, 118, 762)); this.printDocument.DefaultPageSettings.PaperSize = ps; if (Printers.IndexOf(printerName) >= 0) { this.printDocument.PrinterSettings.PrinterName = printerName; } }
public WinPrinterService(ClassicReportDocument document) { this.document = document; pd = new PrintDocument(); pd.PrintPage += OnPrintPage; pd.DefaultPageSettings.Margins.Top = 25; pd.DefaultPageSettings.Margins.Bottom = 25; pd.DefaultPageSettings.Margins.Left = 10; pd.DefaultPageSettings.Margins.Right = 10; System.Drawing.Printing.PaperSize papersize = new System.Drawing.Printing.PaperSize("Custom", document.PaperWidth, document.PaperHeight); pd.DefaultPageSettings.PaperSize = papersize; pd.DocumentName = document.DocumentName; }
public System.Drawing.Printing.PaperSize GetPrintForm(string printerName, string paperName) { System.Drawing.Printing.PaperSize paper = null; System.Drawing.Printing.PrinterSettings printer = new System.Drawing.Printing.PrinterSettings(); printer.PrinterName = printerName; foreach (System.Drawing.Printing.PaperSize ps in printer.PaperSizes) { if (ps.PaperName.ToLower() == paperName.ToLower()) { paper = ps; break; } } return(paper); }
public Reporte_PapeletaIngresadas(ScrollViewer scroll) { this.scrollContenedor = scroll; InitializeComponent(); System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings(); pg.Margins.Top = 0; pg.Margins.Bottom = 0; pg.Margins.Left = 0; pg.Margins.Right = 0; System.Drawing.Printing.PaperSize size = new System.Drawing.Printing.PaperSize(); size.RawKind = (int)PaperKind.B5; pg.PaperSize = size; DemorReport.SetPageSettings(pg); this.DemorReport.RefreshReport(); DemorReport.Reset(); }
void LoadPapers() { comboBox_Papers.DrawMode = DrawMode.OwnerDrawFixed; comboBox_Papers.DrawItem -= new DrawItemEventHandler(comboBox_Papers_DrawItem); comboBox_Papers.DrawItem += new DrawItemEventHandler(comboBox_Papers_DrawItem); comboBox_Papers.DropDownClosed -= new EventHandler(comboBox_Papers_DropDownClosed); comboBox_Papers.DropDownClosed += new EventHandler(comboBox_Papers_DropDownClosed); comboBox_Papers.Items.Clear(); PrintDocument document = new PrintDocument(); foreach (System.Drawing.Printing.PaperSize size in document.PrinterSettings.PaperSizes) { if (size.PaperName.ToLower() == "a4") { DefaultPaperSize = size; } comboBox_Papers.Items.Add(size); } }
System.Drawing.Printing.PaperSize findSuitablePaperSize(System.Drawing.Printing.PaperSize model, PaperKind modelPaper, PrinterSettings.PaperSizeCollection paperSizes) { if (paperSizes.Count == 1) { return(paperSizes[0]); } foreach (System.Drawing.Printing.PaperSize papSize in paperSizes) { if (papSize.Kind != modelPaper) { continue; } //if (papSize.Width < model.Width) continue; //if (papSize.Height < model.Height) continue; return(papSize); } return(null); }
private void Settings() { this.DefaultPageSettings.PaperSize = this.PaperSize; this.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0); this.DefaultPageSettings.Landscape = false; this.PrinterSettings.Copies = _Copies; this.PrinterSettings.MaximumPage = 1; this.PrinterSettings.ToPage = 1; this.PrinterSettings.Duplex = Duplex.Simplex; this.DocumentName = "testing print"; Point = new PointF(Point.X, (float)(Point.Y)); //Ajust for Non-Printable Area /* * if (this.PaperSize.Width > this.PaperSize.Height) * { * this.DefaultPageSettings.Landscape = true; * Point = new PointF(Point.Y, (float)(Point.X)); //Ajust for Non-Printable Area * this.Rotation += 90; * } */ }
private static void PrintPage(object o, PrintPageEventArgs e) { float height = 0; //header String drawString = rHeader; Font drawFont = new Font("Lucida Console", 11, FontStyle.Regular); SolidBrush drawBrush = new SolidBrush(Color.Black); StringFormat drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, 0, 0, drawFormat); SizeF stringSize = new SizeF(); stringSize = e.Graphics.MeasureString(rHeader, drawFont); height = float.Parse(stringSize.Height.ToString()) + height; //stavke drawString = rStavke; drawFont = new Font("Lucida Console", 10, FontStyle.Regular); float y = height; float x = 0.0F; drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); stringSize = e.Graphics.MeasureString(rStavke, drawFont); height = float.Parse(stringSize.Height.ToString()) + height; //Ukupno drawString = rUkupno; drawFont = new Font("Lucida Console", 10, FontStyle.Bold); y = height; x = 0.0F; drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); stringSize = e.Graphics.MeasureString(rUkupno, drawFont); height = float.Parse(stringSize.Height.ToString()) + height; //Naša zahvala drawString = rZahvala; drawFont = new Font("Lucida Console", 12, FontStyle.Regular); y = height; x = 0.0F; drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); stringSize = e.Graphics.MeasureString(rZahvala, drawFont); height = float.Parse(stringSize.Height.ToString()) + height; //Barcode if (img_barcode != null) { System.Drawing.Image img = img_barcode; e.Graphics.DrawImage(img_barcode, 0, height, 250, 50); } //Bottom drawString = rBottom; drawFont = new Font("Lucida Console", 10, FontStyle.Regular); y = height + 60; x = 0.0F; drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); stringSize = e.Graphics.MeasureString(rBottom, drawFont); height = float.Parse(stringSize.Height.ToString()) + height; if (e.HasMorePages) { e.HasMorePages = false; } if (height > e.PageSettings.PaperSize.Height) { PaperSize psNew = new System.Drawing.Printing.PaperSize("Racun", e.PageSettings.PrinterSettings.DefaultPageSettings.PaperSize.Width, (int)height + 1); Size sSize = new Size(psNew.Width, psNew.Height); e.PageSettings.PrinterSettings.DefaultPageSettings.PaperSize = psNew; e.PageSettings.PrinterSettings.DefaultPageSettings.Bounds.Inflate(sSize); e.PageSettings.PrinterSettings.DefaultPageSettings.PrintableArea.Inflate(sSize); e.PageSettings.PrinterSettings.DefaultPageSettings.PrinterSettings.DefaultPageSettings.PrintableArea.Inflate(sSize); e.PageSettings.PaperSize = psNew; e.PageSettings.Bounds.Inflate(sSize); e.PageBounds.Inflate(sSize); e.PageSettings.PrintableArea.Inflate(sSize); e.HasMorePages = true; e.Graphics.Clear(Color.White); e.Graphics.ResetClip(); e.Graphics.Clip.MakeEmpty(); //e.Graphics.Dispose(); //e.Graphics. } }
internal int Add(PaperSize paperSize) { return(_PaperSizes.Add(paperSize)); }
public int Add(PaperSize paperSize) { throw null; }
public void PrintDirect(LocalReport LocalReport, Double WidthInInCM, Double HeightInInCM, String PrinterName) { String deviceInfo = "<DeviceInfo>" + " <OutputFormat>EMF</OutputFormat>" + " <PageWidth>" + WidthInInCM + "cm</PageWidth>" + " <PageHeight>" + HeightInInCM + "cm</PageHeight>" + " <MarginTop>0.0cm</MarginTop>" + " <MarginLeft>0.0cm</MarginLeft>" + " <MarginRight>0.0cm</MarginRight>" + " <MarginBottom>0.0cm</MarginBottom>" + "</DeviceInfo>"; IList <Stream> m_streams; m_streams = new List <Stream>(); Byte[] bytes; String fileName = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "f.emf"); bytes = LocalReport.Render("Image", deviceInfo); if (File.Exists(fileName)) { File.Delete(fileName); } FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite); fs.Write(bytes, 0, bytes.Length); fs.Close(); MemoryStream ms = new MemoryStream(bytes); m_streams.Add(ms); foreach (Stream stream in m_streams) { stream.Position = 0; } if ((m_streams == null) || (m_streams.Count == 0)) { return; } PrintDocument printDoc = new PrintDocument(); printDoc.PrinterSettings.PrinterName = PrinterName; PaperSize pkCustomSize = new System.Drawing.Printing.PaperSize("Custom Paper Size", Convert.ToInt32((WidthInInCM / 2.54) * 100), Convert.ToInt32((HeightInInCM / 2.54) * 100)); printDoc.DefaultPageSettings.PaperSize = pkCustomSize; printDoc.DefaultPageSettings.Margins.Top = 0; printDoc.DefaultPageSettings.Margins.Bottom = 0; printDoc.DefaultPageSettings.Margins.Left = 0; printDoc.DefaultPageSettings.Margins.Right = 0; if (!printDoc.PrinterSettings.IsValid) { String msg = String.Format("Can't find printer \"{0}\".", PrinterName); //MessageBox.Show(msg, "Print Error"); return; } printDoc.PrinterSettings.DefaultPageSettings.PaperSize = printDoc.DefaultPageSettings.PaperSize; printDoc.PrinterSettings.DefaultPageSettings.Margins = printDoc.DefaultPageSettings.Margins; if (m_streams.Count > 0) { ViewState["pageImage"] = new Metafile(m_streams[0]); } printDoc.PrintPage += new PrintPageEventHandler(this.PrintPage); printDoc.Print(); }
private void PrintPage(object o, PrintPageEventArgs e) { float height = 0; try { System.Drawing.Text.PrivateFontCollection privateFonts = new PrivateFontCollection(); privateFonts.AddFontFile("slike/msgothic.ttc"); System.Drawing.Font font = new Font(privateFonts.Families[0], 9.5f); if (Class.PodaciTvrtka.oibTvrtke == "85501330524") { font = new Font(privateFonts.Families[0], 8.5f); } System.Drawing.Text.PrivateFontCollection privateFonts_ukupno = new PrivateFontCollection(); privateFonts_ukupno.AddFontFile("slike/msgothic.ttc"); System.Drawing.Font font_ukupno = new Font(privateFonts.Families[0], 13); if (Class.PodaciTvrtka.oibTvrtke == "85501330524") { font_ukupno = new Font(privateFonts.Families[0], 11); } System.Drawing.Text.PrivateFontCollection privateFonts_mali = new PrivateFontCollection(); privateFonts_ukupno.AddFontFile("slike/msgothic.ttc"); System.Drawing.Font font_mali = new Font(privateFonts.Families[0], 9); if (Class.PodaciTvrtka.oibTvrtke == "85501330524") { font_mali = new Font(privateFonts.Families[0], 8); } try { if (System.IO.File.Exists("C://logo/logo.jpg")) { Image ik = Image.FromFile("C://logo/logo.jpg"); height = ik.Height; Point pp = new Point(0, 0); e.Graphics.DrawImage(ik, 0, 0, 300, 113); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } //header string drawString = _1; Font drawFont = font; SolidBrush drawBrush = new SolidBrush(Color.Black); StringFormat drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, 0, height, drawFormat); SizeF stringSize = new SizeF(); stringSize = e.Graphics.MeasureString(_1, drawFont); height = float.Parse(stringSize.Height.ToString()) + height; //stavke drawString = _2; drawFont = font; float y = height; float x = 0.0F; drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); stringSize = e.Graphics.MeasureString(_2, drawFont); height = float.Parse(stringSize.Height.ToString()) + height; //Ukupno drawString = _3; drawFont = font_ukupno; y = height; x = 0.0F; drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); stringSize = e.Graphics.MeasureString(_3, drawFont); height = float.Parse(stringSize.Height.ToString()) + height; //Naša zahvala drawString = _4; drawFont = font; y = height; x = 0.0F; drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); stringSize = e.Graphics.MeasureString(_4, drawFont); height = float.Parse(stringSize.Height.ToString()) + height; //Barcode //if (img_barcode != null) //{ // System.Drawing.Image img = img_barcode; // e.Graphics.DrawImage(img_barcode, 0, height, 250, 50); // height = 60 + height; //} //Bottom drawString = _5; drawFont = font; y = height; x = 0.0F; drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); stringSize = e.Graphics.MeasureString(_5, drawFont); height = float.Parse(stringSize.Height.ToString()) + height; if (e.HasMorePages) { e.HasMorePages = false; } if (height > e.PageSettings.PaperSize.Height) { PaperSize psNew = new System.Drawing.Printing.PaperSize("Racun", e.PageSettings.PrinterSettings.DefaultPageSettings.PaperSize.Width, (int)height + 1); Size sSize = new Size(psNew.Width, psNew.Height); e.PageSettings.PrinterSettings.DefaultPageSettings.PaperSize = psNew; e.PageSettings.PrinterSettings.DefaultPageSettings.Bounds.Inflate(sSize); e.PageSettings.PrinterSettings.DefaultPageSettings.PrintableArea.Inflate(sSize); e.PageSettings.PrinterSettings.DefaultPageSettings.PrinterSettings.DefaultPageSettings.PrintableArea.Inflate(sSize); e.PageSettings.PaperSize = psNew; e.PageSettings.Bounds.Inflate(sSize); e.PageBounds.Inflate(sSize); e.PageSettings.PrintableArea.Inflate(sSize); e.HasMorePages = true; e.Graphics.Clear(Color.White); e.Graphics.ResetClip(); e.Graphics.Clip.MakeEmpty(); } } catch (Exception ex) { MessageBox.Show("Font za ispis nije pronađen!" + Environment.NewLine + Environment.NewLine + ex.Message, "Upozorenje!"); } }
private static void PrintPage(object o, PrintPageEventArgs e) { float height = 0; System.Drawing.Text.PrivateFontCollection privateFonts = new PrivateFontCollection(); privateFonts.AddFontFile("Slike/msgothic.ttc"); System.Drawing.Font font = new Font(privateFonts.Families[0], Convert.ToInt16(DTpostavke.Rows[0]["font_print_size"].ToString())); System.Drawing.Text.PrivateFontCollection privateFonts_ukupno = new PrivateFontCollection(); privateFonts_ukupno.AddFontFile("Slike/msgothic.ttc"); System.Drawing.Font font_ukupno = new Font(privateFonts.Families[0], Class.PosPrint.fontUkupnoSizeMailiPrinter); try { if (File.Exists("C://logo/logo.jpg")) { Image ik = Image.FromFile("C://logo/logo.jpg"); bool bigerWidth = false; float rezol = 0; if (ik.Size.Width > ik.Size.Height) { bigerWidth = true; rezol = ik.Size.Width / ik.Size.Height; } else { rezol = ik.Size.Height / ik.Size.Width; } int newWidth = ik.Size.Width, newHeight = ik.Size.Height; if ((bigerWidth ? ik.Size.Width : ik.Size.Height) > e.PageSettings.PrintableArea.Size.Width) { if (bigerWidth) { newWidth = (int)e.PageSettings.PrintableArea.Size.Width; newHeight = (ik.Size.Height * newWidth) / ik.Size.Width; } else { newHeight = (int)e.PageSettings.PrintableArea.Size.Width; newWidth = (newHeight * ik.Size.Width) / ik.Size.Height; } } Point pp = new Point(0, 0); e.Graphics.DrawImage(ik, (e.PageSettings.PrintableArea.Size.Width - newWidth) / 2, height, newWidth, newHeight); pageHeight = (int)(height + newHeight); height = newHeight; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } //header string drawString = _1; Font drawFont = font; SolidBrush drawBrush = new SolidBrush(Color.Black); StringFormat drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, 0, height, drawFormat); SizeF stringSize = new SizeF(); stringSize = e.Graphics.MeasureString(_1, drawFont); height = float.Parse(stringSize.Height.ToString()) + height; //stavke float y = 0, x = 0; if (_2.Contains("{[5AR]}") && Class.PosPrint.ispisUkupnoIspodStavkiMaliPrinter) { string[] _2s = _2.Split(new string[] { "{[5AR]}" + Environment.NewLine }, StringSplitOptions.None); drawString = _2s[0]; drawFont = font; y = height; x = 0.0F; drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); stringSize = e.Graphics.MeasureString(_2s[0], drawFont); height = float.Parse(stringSize.Height.ToString()) + height; //Ukupno //string s1 = "UKUPNO:"; //string s2 = ukupno.ToString("#0.00") + " KN"; string s3 = ""; for (int i = 0; i < (RecLineChars - _3.Length - 5); i++) { s3 += " "; } //_3 = s1 + s3 + s2; //_3 = _3.Split(':')[0] + s3 + _3.Split(':')[1]; drawString = _3.ToUpper(); drawFont = font_ukupno; y = height; x = 0.0F; drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); stringSize = e.Graphics.MeasureString(_3, drawFont); height = float.Parse(stringSize.Height.ToString()) + height; drawString = _2s[1]; drawFont = font; y = height; x = 0.0F; drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); stringSize = e.Graphics.MeasureString(_2s[1], drawFont); height = float.Parse(stringSize.Height.ToString()) + height; } else { drawString = _2; drawFont = font; y = height; x = 0.0F; drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); stringSize = e.Graphics.MeasureString(_2, drawFont); height = float.Parse(stringSize.Height.ToString()) + height; } if (!_2.Contains("{[5AR]}") && !Class.PosPrint.ispisUkupnoIspodStavkiMaliPrinter) { //Ukupno drawString = _3; drawFont = font_ukupno; y = height; x = 0.0F; drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); stringSize = e.Graphics.MeasureString(_3, drawFont); height = float.Parse(stringSize.Height.ToString()) + height; } //Naša zahvala drawString = _4; drawFont = font; y = height; x = 0.0F; drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); stringSize = e.Graphics.MeasureString(_4, drawFont); height = float.Parse(stringSize.Height.ToString()) + height; if (dt.Rows.Count > 0) { if (dt.Rows[0]["aktivnost"].ToString() == "DA") { //Barcode if (img_barcode != null) { System.Drawing.Image img = img_barcode; e.Graphics.DrawImage(img_barcode, 0, height, 250, 50); } height = height + 70; } } //Bottom drawString = _5; drawFont = font; y = height; x = 0.0F; drawFormat = new StringFormat(); e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); stringSize = e.Graphics.MeasureString(_5.TrimEnd(), drawFont); height = float.Parse(stringSize.Height.ToString()) + height; try { if (File.Exists("C://logo/logo2.jpg")) { Image ik = Image.FromFile("C://logo/logo2.jpg"); bool bigerWidth = false; float rezol = 0; if (ik.Size.Width > ik.Size.Height) { bigerWidth = true; rezol = ik.Size.Width / ik.Size.Height; } else { rezol = ik.Size.Height / ik.Size.Width; } int newWidth = ik.Size.Width, newHeight = ik.Size.Height; if ((bigerWidth ? ik.Size.Width : ik.Size.Height) > e.PageSettings.PrintableArea.Size.Width) { if (bigerWidth) { newWidth = (int)e.PageSettings.PrintableArea.Size.Width; newHeight = (ik.Size.Height * newWidth) / ik.Size.Width; } else { newHeight = (int)e.PageSettings.PrintableArea.Size.Width; newWidth = (newHeight * ik.Size.Width) / ik.Size.Height; } } Point pp = new Point(0, 0); e.Graphics.DrawImage(ik, (e.PageSettings.PrintableArea.Size.Width - newWidth) / 2, height, newWidth, newHeight); pageHeight = (int)(height + newHeight); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } pageHeight++; if (e.HasMorePages) { e.HasMorePages = false; } if (pageHeight > e.PageSettings.PaperSize.Height) { PaperSize psNew = new System.Drawing.Printing.PaperSize("Racun", e.PageSettings.PrinterSettings.DefaultPageSettings.PaperSize.Width, pageHeight); Size sSize = new Size(psNew.Width, psNew.Height); e.PageSettings.PrinterSettings.DefaultPageSettings.PaperSize = psNew; e.PageSettings.PrinterSettings.DefaultPageSettings.Bounds.Inflate(sSize); e.PageSettings.PrinterSettings.DefaultPageSettings.PrintableArea.Inflate(sSize); e.PageSettings.PrinterSettings.DefaultPageSettings.PrinterSettings.DefaultPageSettings.PrintableArea.Inflate(sSize); e.PageSettings.PaperSize = psNew; e.PageSettings.Bounds.Inflate(sSize); e.PageBounds.Inflate(sSize); e.PageSettings.PrintableArea.Inflate(sSize); e.HasMorePages = true; e.Graphics.Clear(Color.White); e.Graphics.ResetClip(); e.Graphics.Clip.MakeEmpty(); } }
public Class8(System.Drawing.Printing.PaperSize paperSize_1) { this.paperSize_0 = paperSize_1; }
public int Add(PaperSize paperSize) { return(_PaperSizes.Add(paperSize)); }
/// <summary> /// printDocBarcode_BeginPrint /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void printDocBarcode_BeginPrint(object sender, System.Drawing.Printing.PrintEventArgs e) { System.Drawing.Printing.PaperSize ps = new System.Drawing.Printing.PaperSize("标本条码", 196, 118); this.printDocBarcode.DefaultPageSettings.PaperSize = ps; }
void LoadPrinterPaperSizes(string printer, PrinterSettings settings) { int items, ret; IntPtr ptr_names, buff_names = IntPtr.Zero; IntPtr ptr_sizes, buff_sizes = IntPtr.Zero; IntPtr ptr_sizes_enum, buff_sizes_enum = IntPtr.Zero; string name; if (settings.PaperSizes == null) { settings.paper_sizes = new PrinterSettings.PaperSizeCollection(new PaperSize [0]); } else { settings.PaperSizes.Clear(); } items = Win32DeviceCapabilities(printer, null, DCCapabilities.DC_PAPERSIZE, IntPtr.Zero, IntPtr.Zero); if (items == -1) { return; } try { ptr_sizes = buff_sizes = Marshal.AllocHGlobal(items * 2 * 4); ptr_names = buff_names = Marshal.AllocHGlobal(items * 64 * 2); ptr_sizes_enum = buff_sizes_enum = Marshal.AllocHGlobal(items * 2); ret = Win32DeviceCapabilities(printer, null, DCCapabilities.DC_PAPERSIZE, buff_sizes, IntPtr.Zero); if (ret == -1) { // the finally clause will free the unmanaged memory before returning return; } ret = Win32DeviceCapabilities(printer, null, DCCapabilities.DC_PAPERS, buff_sizes_enum, IntPtr.Zero); ret = Win32DeviceCapabilities(printer, null, DCCapabilities.DC_PAPERNAMES, buff_names, IntPtr.Zero); int x, y; PaperSize ps; PaperKind kind; for (int i = 0; i < ret; i++) { x = Marshal.ReadInt32(ptr_sizes, i * 8); y = Marshal.ReadInt32(ptr_sizes, (i * 8) + 4); x = PrinterUnitConvert.Convert(x, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display); y = PrinterUnitConvert.Convert(y, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display); name = Marshal.PtrToStringUni(ptr_names); ptr_names = new IntPtr(ptr_names.ToInt64() + 64 * 2); kind = (PaperKind)Marshal.ReadInt16(ptr_sizes_enum); ptr_sizes_enum = new IntPtr(ptr_sizes_enum.ToInt64() + 2); ps = new PaperSize(name, x, y); ps.RawKind = (int)kind; settings.PaperSizes.Add(ps); } } finally { if (buff_names != IntPtr.Zero) { Marshal.FreeHGlobal(buff_names); } if (buff_sizes != IntPtr.Zero) { Marshal.FreeHGlobal(buff_sizes); } if (buff_sizes_enum != IntPtr.Zero) { Marshal.FreeHGlobal(buff_sizes_enum); } } }
public void print() { PrintDialog pd = new PrintDialog(); pdoc = new PrintDocument(); PrinterSettings ps = new PrinterSettings(); Font font = new Font("Courier New", 15); PaperSize psize = new PaperSize("Custom", 300, 100); ps.DefaultPageSettings.PaperSize = psize; pd.Document = pdoc; pd.Document.DefaultPageSettings.PaperSize = psize; pdoc.DefaultPageSettings.PaperSize = psize; pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage); DialogResult result = pd.ShowDialog(); if (result == DialogResult.OK) { PrintPreviewDialog pp = new PrintPreviewDialog(); pp.Document = pdoc; result = pp.ShowDialog(); if (result == DialogResult.OK) { pdoc.Print(); } } }