コード例 #1
0
        public bool Find(Int32 ID)
        {
            //this.CallID = String.Empty;

            if (ID == 0)
            {
                Clear();
                return(false);
            }

            DataRow Row = Global.oMySql.GetDataRow(String.Format("Select * From {0} Where ID='{1}'", TableName, ID), TableName);

            if (Row == null)
            {
                Clear();
                return(false);
            }

            this.ID              = Row["ID"].ToString();
            this.Description     = Row["Description"].ToString();
            this.PointX          = (Double)Row["PointX"];
            this.PointY          = (Double)Row["PointY"];
            this.PaperSizeWidth  = (Double)Row["PaperSizeWidth"];
            this.PaperSizeHeight = (Double)Row["PaperSizeHeight"];
            this.FontName        = Row["FontName"].ToString();
            this.FontSize        = (Int32)Row["FontSize"];
            this.Bold            = (Boolean)Row["Bold"];
            this.Rotation        = (Int32)Row["Rotation"];

            this.PaperSize = new System.Drawing.Printing.PaperSize("General", (int)(PaperSizeWidth * 100), (int)(PaperSizeHeight * 100));
            this.Point     = new System.Drawing.PointF((float)(PointX * 100), (float)(PointY * 100));
            return(true);
        }
コード例 #2
0
        /// <summary>
        /// 打印
        /// </summary>
        public void Print()
        {
            //Neusoft.FrameWork.WinForms.Classes.Print print = new Neusoft.FrameWork.WinForms.Classes.Print();
            //print.SetPageSize(new System.Drawing.Printing.PaperSize("Letter", 780, 640));
            //print.ControlBorder = Neusoft.FrameWork.WinForms.Classes.enuControlBorder.None;
            //print.PrintPreview(20, 10, this);

            Neusoft.FrameWork.WinForms.Classes.Print print = new Neusoft.FrameWork.WinForms.Classes.Print();

            System.Drawing.Printing.PaperSize paperSize = new System.Drawing.Printing.PaperSize();
            paperSize.PaperName = "xxx" + (new Random()).Next(10000).ToString();//随便编个名字
            try
            {
                int width     = 960;
                int curHeight = this.Height;
                int addHeight = (this.neuSpread1_Sheet1.RowCount - 1) * (int)this.neuSpread1_Sheet1.Rows[0].Height;

                int additionAddHeight = 3 * (int)this.neuSpread1_Sheet1.Rows[0].Height;

                paperSize.Width  = width;
                paperSize.Height = (addHeight + curHeight + additionAddHeight);
            }
            catch (Exception ex)
            {
                MessageBox.Show("设置汇总发药纸张出错>>" + ex.Message);
            }

            print.SetPageSize(paperSize);
            print.PrintPreview(15, 10, this);
        }
コード例 #3
0
 protected override void ApplyPageSettings()
 {
     base.ApplyPageSettings();
     System.Drawing.Printing.PaperSize paperSize = GetPaperSizeEx(_PaperName);
     this.PrintingSystem.PageSettings.Assign(this.Margins, this.PaperKind, new System.Drawing.Size(paperSize.Width, paperSize.Height), this.Landscape);
     this.PrintingSystem.PageSettings.PaperName = _PaperName;
 }
コード例 #4
0
        /// <summary>
        /// 打印报表
        /// </summary>
        /// <param name="g"></param>
        /// <param name="page"></param>
        /// <param name="clipRectangle"></param>
        public void Print(Graphics g, int page, System.Drawing.Printing.PaperSize paperSize)
        {
            if (_Pages == null)
            {
                return;
            }
            _Left      = 0;
            _Top       = 0;
            _hScroll   = 0;
            _vScroll   = 0;
            _DpiX      = g.DpiX;
            _DpiY      = g.DpiY;
            g.PageUnit = GraphicsUnit.Pixel;
            if (_Pages.EnablePrintZoom == true)
            {
                //PrintDocument的PaperSize的单位是百分之一英寸
                float widthZoomTemp  = ((float)paperSize.Width / 100) / ((float)_Pages.PageWidth);
                float heightZoomTemp = ((float)paperSize.Height / 100) / ((float)_Pages.PageHeight);

                g.ScaleTransform(Math.Min(widthZoomTemp, heightZoomTemp), Math.Min(widthZoomTemp, heightZoomTemp));
            }
            else
            {
                g.ScaleTransform(1, 1);
            }
            RectangleF r = new RectangleF(0, 0, InchesToPixelX(_Pages.PageWidth), InchesToPixelY(_Pages.PageHeight));

            DrawPage(g, _Pages.Pages [page], r);
        }
コード例 #5
0
        private void btn_fis_Click(object sender, EventArgs e)
        {
            printDocument1.DocumentName = "Fis Sureti";
            //printDialog1.Document = printDocument1;
            //if (printDialog1.ShowDialog() == DialogResult.OK)
            //{
            //    makePrintStr();
            //    printDocument1.Print();
            //}

            makePrintStr();
            System.Drawing.Printing.PaperSize         ps = new System.Drawing.Printing.PaperSize("new", 400, PublicVariables.kagit_boyu);
            System.Drawing.Printing.PrinterResolution pr = new System.Drawing.Printing.PrinterResolution();
            pr.Kind = System.Drawing.Printing.PrinterResolutionKind.Draft;

            printDocument1.DefaultPageSettings.PaperSize         = ps;
            printDocument1.DefaultPageSettings.PrinterResolution = pr;
            printDocument1.Print();

            //string s = RawPrinterHelper.GetDefaultPrinterName();

            //RawPrinterHelper.SendStringToPrinter(s, print_str);
            if (durum == "G")
            {
                this.Close();
            }
            else
            {
            }
        }
コード例 #6
0
        private void PageSelect()
        {
            PageSetupDialog p = new PageSetupDialog();

            System.Drawing.Printing.PageSettings pSet = new System.Drawing.Printing.PageSettings();
            pSet.Landscape = myPageSetup.Landscape;
            System.Drawing.Printing.PaperSize pSize = new System.Drawing.Printing.PaperSize();
            pSize.RawKind  = myPageSetup.PaperSize;
            pSet.PaperSize = pSize;
            p.PageSettings = pSet;
            if (p.ShowDialog() == DialogResult.OK)
            {
                myPageSetup.Landscape = pSet.Landscape;
                myPageSetup.PaperSize = pSet.PaperSize.RawKind;
                myPageSetup.PaperName = pSet.PaperSize.PaperName;
                if (myPageSetup.Landscape)
                {
                    myPageSetup.PageWidth   = pSet.PaperSize.Height;
                    myPageSetup.PageHeight  = pSet.PaperSize.Width;
                    myPageSetup.ScaleWidth  = pSet.PrintableArea.Height;
                    myPageSetup.ScaleHeight = pSet.PrintableArea.Width;
                }
                else
                {
                    myPageSetup.PageWidth   = pSet.PaperSize.Width;
                    myPageSetup.PageHeight  = pSet.PaperSize.Height;
                    myPageSetup.ScaleWidth  = pSet.PrintableArea.Width;
                    myPageSetup.ScaleHeight = pSet.PrintableArea.Height;
                }
                RefreshPrintName(pSet.PaperSize);
            }
        }
コード例 #7
0
 /// <summary>
 /// 根据[快递模板模型]初始化
 /// </summary>
 /// <param name="expInfo">快递模板模型</param>
 /// <param name="textLength">文本达到长度后自动换行</param>
 public LabelPrintModel(ExpressModel expInfo, int textLength)
 {
     标签   = expInfo.标签;
     起始点  = new System.Drawing.PointF(expInfo.水平平移 / 0.254f, expInfo.垂直平移 / 0.254f);
     纸张尺寸 = new System.Drawing.Printing.PaperSize(expInfo.称, expInfo.宽, expInfo.高);
     文本长度 = textLength;
 }
コード例 #8
0
        private void Print_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var idx = (TrnPengirimanModel)Dgv_Home.SelectedItem;

                if (idx == null)
                {
                    MessageBox.Show("Tidak ada data yg dipilih", "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }

                using (new WaitCursor())
                {
                    var connectString       = ConfigurationManager.ConnectionStrings["TIMBANGANEntities"].ConnectionString;
                    var entityStringBuilder = new EntityConnectionStringBuilder(connectString);
                    SqlConnectionStringBuilder SqlConnection = new SqlConnectionStringBuilder(entityStringBuilder.ProviderConnectionString);
                    var PrinterName = ConfigurationManager.AppSettings["PrinterName"];

                    ReportDocument cryRpt = new ReportDocument();

                    // this will be in a temp directory.
                    string SystemPath = System.AppDomain.CurrentDomain.BaseDirectory;
                    //once you have the path you get the directory with:
                    var directory = System.IO.Path.GetDirectoryName(SystemPath);


                    cryRpt.Load(SystemPath + "\\Reports\\ReportSuratJalan3.rpt");
                    cryRpt.SetDatabaseLogon(SqlConnection.UserID, SqlConnection.Password, SqlConnection.DataSource, SqlConnection.InitialCatalog);
                    cryRpt.SetParameterValue("id", idx.ID);

                    //cryRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows, fullPath);

                    System.Drawing.Printing.PrinterSettings printersettings = new System.Drawing.Printing.PrinterSettings();
                    System.Drawing.Printing.PageSettings    pageSettings    = new System.Drawing.Printing.PageSettings();
                    var paper = new System.Drawing.Printing.PaperSize("Custom", 850, 650);

                    printersettings.DefaultPageSettings.Landscape = false;
                    printersettings.DefaultPageSettings.PaperSize = paper;

                    pageSettings.PaperSize = paper;
                    pageSettings.Margins   = new System.Drawing.Printing.Margins(0, 0, 0, 0);
                    pageSettings.Landscape = false;

                    var nama = System.Drawing.Printing.PrinterSettings.InstalledPrinters;

                    printersettings.PrinterName = PrinterName;

                    cryRpt.PrintToPrinter(printersettings, pageSettings, false);
                }

                MessageBox.Show("File Printing", Constans.SubmitMessageTittle.Sukses, MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception exp)
            {
                LogError.WriteError(exp);
                MessageBox.Show(Constans.SubmitMessage.Error, Constans.SubmitMessageTittle.Error, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #9
0
        private void Print_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(Filter_Tanggal.Text))
                {
                    MessageBox.Show("Filter tidak boleh kosong", "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }

                using (new WaitCursor())
                {
                    var connectString       = ConfigurationManager.ConnectionStrings["TIMBANGANEntities"].ConnectionString;
                    var entityStringBuilder = new EntityConnectionStringBuilder(connectString);
                    SqlConnectionStringBuilder SqlConnection = new SqlConnectionStringBuilder(entityStringBuilder.ProviderConnectionString);
                    var PrinterName = ConfigurationManager.AppSettings["PrinterName"];

                    ReportDocument cryRpt = new ReportDocument();

                    // this will be in a temp directory.
                    string SystemPath = System.AppDomain.CurrentDomain.BaseDirectory;
                    //once you have the path you get the directory with:
                    var directory = System.IO.Path.GetDirectoryName(SystemPath);

                    var Date = Convert.ToDateTime(Filter_Tanggal.Text);

                    cryRpt.Load(SystemPath + "\\Reports\\ReportRealisasiHarian.rpt");
                    cryRpt.SetDatabaseLogon(SqlConnection.UserID, SqlConnection.Password, SqlConnection.DataSource, SqlConnection.InitialCatalog);
                    cryRpt.SetParameterValue("@Date", Date.ToString("yyyy-MM-dd"));

                    //cryRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows, fullPath);

                    System.Drawing.Printing.PrinterSettings printersettings = new System.Drawing.Printing.PrinterSettings();
                    System.Drawing.Printing.PageSettings    pageSettings    = new System.Drawing.Printing.PageSettings();
                    var paper = new System.Drawing.Printing.PaperSize("A4", 650, 850);

                    printersettings.DefaultPageSettings.Landscape = false;
                    printersettings.DefaultPageSettings.PaperSize = paper;

                    pageSettings.PaperSize = paper;
                    pageSettings.Margins   = new System.Drawing.Printing.Margins(0, 0, 0, 0);
                    pageSettings.Landscape = false;

                    var nama = System.Drawing.Printing.PrinterSettings.InstalledPrinters;

                    printersettings.PrinterName = PrinterName;

                    cryRpt.PrintToPrinter(printersettings, pageSettings, false);
                }

                MessageBox.Show("File Printing", Constans.SubmitMessageTittle.Sukses, MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception exp)
            {
                LogError.WriteError(exp);
                MessageBox.Show(Constans.SubmitMessage.Error, Constans.SubmitMessageTittle.Error, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #10
0
 internal Rectangle GetBounds(IntPtr modeHandle)
 {
     System.Drawing.Printing.PaperSize paperSize = this.GetPaperSize(modeHandle);
     if (this.GetLandscape(modeHandle))
     {
         return(new Rectangle(0, 0, paperSize.Height, paperSize.Width));
     }
     return(new Rectangle(0, 0, paperSize.Width, paperSize.Height));
 }
コード例 #11
0
 public void Print()
 {
     Neusoft.FrameWork.WinForms.Classes.Print p = new Neusoft.FrameWork.WinForms.Classes.Print();
     p.IsResetPage = true;
     System.Drawing.Printing.PaperSize pageSize = this.getPaperSizeForInput();
     p.SetPageSize(pageSize);
     p.PrintPage(15, 10, this);
     //p.PrintPreview(15, 10, this.neuPanel1);
 }
コード例 #12
0
        private void Btn_PrintToPrinter_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (new WaitCursor())
                {
                    var connectString       = ConfigurationManager.ConnectionStrings["TIMBANGANEntities"].ConnectionString;
                    var entityStringBuilder = new EntityConnectionStringBuilder(connectString);
                    SqlConnectionStringBuilder SqlConnection = new SqlConnectionStringBuilder(entityStringBuilder.ProviderConnectionString);
                    var PrinterName = ConfigurationManager.AppSettings["PrinterName"];

                    ReportDocument cryRpt = new ReportDocument();

                    // this will be in a temp directory.
                    string SystemPath = System.AppDomain.CurrentDomain.BaseDirectory;
                    //once you have the path you get the directory with:
                    var directory = System.IO.Path.GetDirectoryName(SystemPath);

                    var Id = 0;
                    try
                    {
                        Id = Int32.Parse(txtID.Text);
                    }
                    catch (Exception) { }

                    cryRpt.Load(SystemPath + "\\Reports\\ReportSlipTimbangan.rpt");
                    cryRpt.SetDatabaseLogon(SqlConnection.UserID, SqlConnection.Password, SqlConnection.DataSource, SqlConnection.InitialCatalog);
                    cryRpt.SetParameterValue("id", Id);

                    //cryRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows, fullPath);

                    System.Drawing.Printing.PrinterSettings printersettings = new System.Drawing.Printing.PrinterSettings();
                    System.Drawing.Printing.PageSettings    pageSettings    = new System.Drawing.Printing.PageSettings();
                    var paper = new System.Drawing.Printing.PaperSize("Custom", 300, 600);

                    printersettings.DefaultPageSettings.Landscape = false;
                    printersettings.DefaultPageSettings.PaperSize = paper;

                    pageSettings.PaperSize = paper;
                    pageSettings.Margins   = new System.Drawing.Printing.Margins(0, 0, 0, 0);
                    pageSettings.Landscape = false;

                    var nama = System.Drawing.Printing.PrinterSettings.InstalledPrinters;

                    printersettings.PrinterName = PrinterName;

                    cryRpt.PrintToPrinter(printersettings, pageSettings, false);

                    MessageBox.Show("File Printing", Constans.SubmitMessageTittle.Sukses, MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            catch (Exception exp)
            {
                LogError.WriteError(exp);
                MessageBox.Show(Constans.SubmitMessage.Error, Constans.SubmitMessageTittle.Error, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #13
0
 void UpdatePrintArea()
 {
     printArea.autoPrintArea      = checkBoxAutomatic.Checked;
     printArea.restrictToPageSize = checkBoxFixSizeToPaper.Checked;
     System.Drawing.Printing.PaperSize paperSize = paperSizeControl.PaperSize;
     printArea.pageWidth          = paperSize.Width;
     printArea.pageHeight         = paperSize.Height;
     printArea.pageMargins        = paperSizeControl.MarginSize;
     printArea.pageLandscape      = paperSizeControl.Landscape;
     printArea.printAreaRectangle = controller.SetPrintAreaCurrentRectangle();
 }
コード例 #14
0
 private void Clear()
 {
     ID          = "";
     Description = "";
     PointX      = 0.00;
     PointY      = 0.00;
     FontName    = "";
     FontSize    = 0;
     Bold        = false;
     Rotation    = 0;
     PaperSize   = new System.Drawing.Printing.PaperSize();
     Point       = new System.Drawing.PointF();
 }
コード例 #15
0
 public int PrintPreview()
 {
     Neusoft.FrameWork.WinForms.Classes.Print p = new Neusoft.FrameWork.WinForms.Classes.Print();
     //纸张配置
     p.ShowPageSetup();
     p.IsHaveGrid = true;
     //打印起始终止页面配置
     p.ShowPrintPageDialog();
     System.Drawing.Printing.PaperSize size = new System.Drawing.Printing.PaperSize("Letter", 813, 1064);
     p.SetPageSize(size);
     //打印预览
     return(p.PrintPreview(10, 60, this.panelPrint));
 }
コード例 #16
0
        private void RefreshPrintName(System.Drawing.Printing.PaperSize pSize)
        {
            float x, y;

            checkBoxRoate.Enabled = myPageSetup.Landscape;
            lblPrint.Text         = myPageSetup.PrintName;
            lblPage.Text          = pSize.PaperName + "纸张规格(宽 x 高): " + ((int)(myPageSetup.PageWidth / PrintAssign.PixPerMM)).ToString() + " x " + ((int)(myPageSetup.PageHeight / PrintAssign.PixPerMM)).ToString();
            lblPageSize.Text      = "有效范围(宽 x 高): " + ((int)(myPageSetup.ScaleWidth / PrintAssign.PixPerMM)).ToString() + " x " + ((int)(myPageSetup.ScaleHeight / PrintAssign.PixPerMM)).ToString();
            if (myPageSetup.SupportColor(myPageSetup.PrintName))
            {
                chkColor.Text    = "使用彩色打印";
                chkColor.Checked = true;
                chkColor.Enabled = true;
            }
            else
            {
                chkColor.Text    = "使用彩色打印(打印机不能打印彩色)";
                chkColor.Checked = false;
                chkColor.Enabled = false;
            }
            x = myPageSetup.ScaleWidth;
            y = myPageSetup.ScaleHeight;
            if (chkFullPage.Checked)
            {
                txtWidth.Text  = ((int)(x / PrintAssign.PixPerMM)).ToString();
                txtHeight.Text = ((int)(y / PrintAssign.PixPerMM)).ToString();
            }
            if (mWidth / x < mHeight / y)
            {
                Ratio = mWidth / x;
            }
            else
            {
                Ratio = mHeight / y;
            }
            picPrintRange.Width  = (int)(myPageSetup.PageWidth * Ratio) + 3;
            picPrintRange.Height = (int)(myPageSetup.PageHeight * Ratio) + 3;
            picPreview.Width     = (int)(x * Ratio) + 1;
            picPreview.Height    = (int)(y * Ratio) + 1;
            picPrintRange.Top    = mTop + (mHeight - picPrintRange.Height) / 2;
            picPrintRange.Left   = mLeft + (mWidth - picPrintRange.Width) / 2;
            picPreview.Top       = (picPrintRange.Height - picPreview.Height) / 2;
            picPreview.Left      = (picPrintRange.Width - picPreview.Width) / 2;
            picPrintRange.Width  = (int)(myPageSetup.PageWidth * Ratio) + 6;
            picPrintRange.Height = (int)(myPageSetup.PageHeight * Ratio) + 6;
            Lbl_Ratio.Text       = "比例  1:" + (int)(1 / Ratio);
            //picPreview.Scale(new SizeF(1/Ratio, 1/Ratio));
            //picPreview.Scale(new SizeF(1 , 1));
            picPreview.Refresh();
        }
コード例 #17
0
ファイル: LabelPrinter.cs プロジェクト: ericramses/YPILIS
        public virtual void Print()
        {
            System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument();
            printDocument.PrinterSettings.PrinterName = this.m_PrintQueue.FullName;

            if (this.m_PrintQueue.FullName == "SlideMate AS")
            {
                System.Drawing.Printing.PaperSize paperSize = new System.Drawing.Printing.PaperSize("Label", 100, 100);
                printDocument.PrinterSettings.DefaultPageSettings.PaperSize = paperSize;
            }

            printDocument.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDocument_PrintPage);
            printDocument.Print();
        }
コード例 #18
0
 private void reportViewer1_Load(object sender, EventArgs e)
 {
     System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
     pg.Margins.Top    = 2;
     pg.Margins.Bottom = 0;
     // pg.Margins.Left = 80;
     //  pg.Margins.Right = 0;
     //  pg.Landscape = true;
     System.Drawing.Printing.PaperSize size = new System.Drawing.Printing.PaperSize();
     // size.RawKind = (int)PaperKind.A5;
     // pg.PaperSize = size;
     reportViewer1.SetPageSettings(pg);
     this.reportViewer1.RefreshReport();
 }
コード例 #19
0
        } // End Sub WriteDefaultLayoutToPdf

        /// <summary>
        /// Write the default layout of a model to a PDF file.
        /// </summary>
        /// <remarks>
        /// Depending on the model's setting this either writes the active layout or the model space to the PDF.
        /// This code will center the model/layout on top of the page.
        /// </remarks>
        /// <param name="model">DXF model to write</param>
        /// <param name="paperSize">targeted paper size</param>
        /// <param name="margin">margin around model print in inches</param>
        /// <param name="outfile">path of PDF output file</param>
        /// <param name="embedFonts">embed fonts into PDF?</param>
        /// <param name="lineWeight">default line weight in 100th of mm</param>
        public static void WriteDefaultLayoutToPdf(DxfModel model, System.Drawing.Printing.PaperSize paperSize, float margin, string outfile, bool embedFonts, short lineWeight)
        {
            DxfLayout layout = model.Header.ShowModelSpace ? null : model.ActiveLayout;

            if (layout != null)
            {
                // output layout
                WriteLayoutToPdf(model, layout, paperSize, margin, outfile, embedFonts, lineWeight);
            }
            else
            {
                // output model
                WriteModelToPdf(model, paperSize, margin, outfile, embedFonts, lineWeight);
            }
        } // End Sub WriteDefaultLayoutToPdf
コード例 #20
0
 public virtual void Import()
 {
     // TODO:  添加 ucReportBase.Import 实现
     //接口中没有打印设置,只能使用这个了
     Neusoft.FrameWork.WinForms.Classes.Print p = new Neusoft.FrameWork.WinForms.Classes.Print();
     //纸张配置
     p.ShowPageSetup();
     p.IsHaveGrid = true;
     //打印起始终止页面配置
     p.ShowPrintPageDialog();
     System.Drawing.Printing.PaperSize size = new System.Drawing.Printing.PaperSize("Letter", 813, 1064);
     p.SetPageSize(size);
     //打印预览
     p.PrintPreview(10, 60, this.panelPrint);
 }
コード例 #21
0
        public System.Drawing.Printing.PaperSize Paper(System.Drawing.Printing.PrintDocument document, System.Drawing.Printing.PaperKind paperKind)
        {
            System.Drawing.Printing.PaperSize paper = null;

            foreach (System.Drawing.Printing.PaperSize paperSize in document.PrinterSettings.PaperSizes)
            {
                if (paperSize.Kind.Equals(paperKind))
                {
                    paper = paperSize;
                    break;
                }
            }

            return(paper);
        }
コード例 #22
0
 private void SearchCustomar_Load(object sender, EventArgs e)
 {
     System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
     pg.Margins.Top    = 2;
     pg.Margins.Bottom = 0;
     pg.Margins.Left   = 80;
     //  pg.Margins.Right = 0;
     pg.Landscape = true;
     System.Drawing.Printing.PaperSize size = new System.Drawing.Printing.PaperSize();
     // size.RawKind = (int)PaperKind.A5;
     // pg.PaperSize = size;
     reportViewer1.SetPageSettings(pg);
     this.reportViewer1.RefreshReport();
     // TODO: This line of code loads data into the 'gudduDataSet3.MyOrder' table. You can move, or remove it, as needed.
 }
コード例 #23
0
        } // End Sub WriteDefaultLayoutToPdf

        /// <summary>
        /// Write a complete model to a PDF file.
        /// </summary>
        /// <remarks>
        /// The model is scaled to fit the paper inside the margin.
        /// This code will center the model on top of the page.
        /// </remarks>
        /// <param name="model">DXF model to write</param>
        /// <param name="paperSize">targeted paper size</param>
        /// <param name="margin">margin around model print in inches</param>
        /// <param name="outfile">path of PDF output file</param>
        /// <param name="embedFonts">embed fonts into PDF?</param>
        /// <param name="lineWeight">default line weight in 100th of mm</param>
        private static void WriteModelToPdf(DxfModel model, System.Drawing.Printing.PaperSize paperSize, float margin, string outfile, bool embedFonts, short lineWeight)
        {
            WW.Cad.Drawing.BoundsCalculator boundsCalculator = new WW.Cad.Drawing.BoundsCalculator();
            boundsCalculator.GetBounds(model);
            Bounds3D bounds = boundsCalculator.Bounds;

            // Lengths in inches.
            float pageWidth  = paperSize.Width / 100f;
            float pageHeight = paperSize.Height / 100f;

            // Scale and transform such that its fits max width/height
            // and the top middle of the cad drawing will match the
            // top middle of the pdf page.
            // The transform transforms to pdf pixels.
            double   scaling;
            Matrix4D to2DTransform = DxfUtil.GetScaleTransform(
                bounds.Corner1,
                bounds.Corner2,
                new Point3D(bounds.Center.X, bounds.Corner2.Y, 0d),
                new Point3D(new Vector3D(margin, margin, 0d) * PdfExporter.InchToPixel),
                new Point3D(new Vector3D(pageWidth - margin, pageHeight - margin, 0d) * PdfExporter.InchToPixel),
                new Point3D(new Vector3D(pageWidth / 2d, pageHeight - margin, 0d) * PdfExporter.InchToPixel),
                out scaling
                );

            using (System.IO.Stream stream = System.IO.File.Create(outfile))
            {
                PdfExporter pdfGraphics = new PdfExporter(stream);
                pdfGraphics.ExportLayers      = true;
                pdfGraphics.UseMultipleLayers = false;
                pdfGraphics.EmbedFonts        = embedFonts;
                WW.Cad.Drawing.GraphicsConfig config = (WW.Cad.Drawing.GraphicsConfig)WW.Cad.Drawing.GraphicsConfig.AcadLikeWithWhiteBackground.Clone();
                config.TryDrawingTextAsText = embedFonts;
                config.DefaultLineWeight    = lineWeight;

                pdfGraphics.DrawPage(
                    model,
                    config,
                    to2DTransform,
                    scaling,
                    null,
                    null,
                    paperSize
                    );

                pdfGraphics.EndDocument();
            } // End Using stream
        }     // End Sub WriteModelToPdf
コード例 #24
0
        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);
        }
コード例 #25
0
 public MySheet(MySheet oldSheet)
 {
     sheet            = oldSheet.sheet;
     SheetNumberInt   = oldSheet.SheetNumberInt;
     revitPaperSize   = oldSheet.revitPaperSize;
     windowsPaperSize = oldSheet.windowsPaperSize;
     pSetting         = oldSheet.pSetting;
     IsVertical       = oldSheet.IsVertical;
     SheetId          = oldSheet.sheet.Id.IntegerValue;
     IsPrintable      = oldSheet.IsPrintable;
     titleBlocks      = oldSheet.titleBlocks;
     widthMm          = oldSheet.widthMm;
     heigthMm         = oldSheet.heigthMm;
     ForceColored     = oldSheet.ForceColored;
     PdfFileName      = oldSheet.PdfFileName;
 }
コード例 #26
0
        private void btnAplicar_Click(object sender, EventArgs e)
        {
            if (cbHoja.ValueInt == 0)
            {
                System.Drawing.Printing.PaperSize paperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
                documento1.DefaultPageSettings.PaperSize = paperSize;
            }
            else
            {
                System.Drawing.Printing.PaperSize paperSize = new System.Drawing.Printing.PaperSize("Ticket", (int)(this.txtWidth.ValueInt / 0.254), (int)(this.txtHeight.ValueInt / 0.254) * EntradaCantidad.ValueInt);

                documento1.DefaultPageSettings.PaperSize = paperSize;
            }
            VistaPrevia.Document = documento1;
            VistaPrevia.Refresh();
            UpdateData();
        }
コード例 #27
0
        public void Print(bool isPreview)
        {
            Neusoft.FrameWork.WinForms.Classes.Print p = new Neusoft.FrameWork.WinForms.Classes.Print();
            p.IsResetPage = true;
            System.Drawing.Printing.PaperSize pageSize = this.getPaperSizeForInput();
            p.SetPageSize(pageSize);
            p.ControlBorder = Neusoft.FrameWork.WinForms.Classes.enuControlBorder.None;

            if (isPreview)
            {
                p.PrintPreview(15, 10, this);
            }
            else
            {
                p.PrintPage(15, 10, this);
            }
            //p.PrintPreview(15, 10, this.neuPanel1);
        }
コード例 #28
0
        /// <summary>
        /// 入库单的纸张高度设置
        /// 默认情况下是三行入库数据的高度
        /// </summary>
        private System.Drawing.Printing.PaperSize getPaperSizeForInput()
        {
            System.Drawing.Printing.PaperSize paperSize = new System.Drawing.Printing.PaperSize();
            paperSize.PaperName = "cli" + System.DateTime.Now.ToString();
            try
            {
                int width = 820;
                //int width = this.Width;
                int curHeight = this.Height;
                int addHeight = (this.neuSpread1_Sheet1.RowCount - 1) * (int)this.neuSpread1_Sheet1.Rows[0].Height;

                paperSize.Width  = width;
                paperSize.Height = (addHeight + curHeight);
            }
            catch (Exception ex)
            {
                MessageBox.Show("设置入库打印纸张出错>>" + ex.Message);
            }
            return(paperSize);
        }
コード例 #29
0
        /// <summary>
        /// 打印
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="neuObject"></param>
        /// <returns></returns>
        protected override int OnPrint(object sender, object neuObject)
        {
            if (this.nineSpread1_Sheet1.RowCount > 0)
            {
                FarPoint.Win.Spread.PrintInfo pi = new FarPoint.Win.Spread.PrintInfo();

                pi.Header     = "/r /fz\"12\" 第 /p 页 共 /pc 页";
                pi.ShowBorder = false;

                float len = 0f;
                for (int cidx = 0; cidx < this.nineSpread1_Sheet1.Columns.Count; cidx++)
                {
                    len += this.nineSpread1_Sheet1.Columns[cidx].Width;
                }

                System.Drawing.Printing.PaperSize ps = new System.Drawing.Printing.PaperSize();
                ps.Width     = 1575;                                                     //px
                ps.Height    = NineVigor.FrameWork.Function.NConvert.ToInt32(945) + 134; //px
                ps.PaperName = "sss";

                pi.PaperSize = ps;


                pi.Margin.Bottom = 64;
                pi.Margin.Left   = 60;
                pi.Margin.Top    = 0;
                pi.Margin.Right  = 0;

                pi.UseMax = false;
                this.nineSpread1_Sheet1.PrintInfo = pi;

                this.nineSpread1.PrintSheet(this.nineSpread1.ActiveSheetIndex);

                return(1);
            }
            else
            {
                MessageBox.Show("没有要打印的数据");
                return(-1);
            }
        }
コード例 #30
0
 public void SetHdevmode(IntPtr hdevmode)
 {
     IntSecurity.AllPrintingAndUnmanagedCode.Demand();
     if (hdevmode == IntPtr.Zero)
     {
         throw new ArgumentException(System.Drawing.SR.GetString("InvalidPrinterHandle", new object[] { hdevmode }));
     }
     SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)UnsafeNativeMethods.PtrToStructure(SafeNativeMethods.GlobalLock(new HandleRef(null, hdevmode)), typeof(SafeNativeMethods.DEVMODE));
     if ((mode.dmFields & 0x800) == 0x800)
     {
         this.color = mode.dmColor == 2;
     }
     if ((mode.dmFields & 1) == 1)
     {
         this.landscape = mode.dmOrientation == 2;
     }
     this.paperSize         = this.PaperSizeFromMode(mode);
     this.paperSource       = this.PaperSourceFromMode(mode);
     this.printerResolution = this.PrinterResolutionFromMode(mode);
     SafeNativeMethods.GlobalUnlock(new HandleRef(null, hdevmode));
 }
コード例 #31
0
 public void SetHdevmode(IntPtr hdevmode)
 {
     IntSecurity.AllPrintingAndUnmanagedCode.Demand();
     if (hdevmode == IntPtr.Zero)
     {
         throw new ArgumentException(System.Drawing.SR.GetString("InvalidPrinterHandle", new object[] { hdevmode }));
     }
     SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE) UnsafeNativeMethods.PtrToStructure(SafeNativeMethods.GlobalLock(new HandleRef(null, hdevmode)), typeof(SafeNativeMethods.DEVMODE));
     if ((mode.dmFields & 0x800) == 0x800)
     {
         this.color = mode.dmColor == 2;
     }
     if ((mode.dmFields & 1) == 1)
     {
         this.landscape = mode.dmOrientation == 2;
     }
     this.paperSize = this.PaperSizeFromMode(mode);
     this.paperSource = this.PaperSourceFromMode(mode);
     this.printerResolution = this.PrinterResolutionFromMode(mode);
     SafeNativeMethods.GlobalUnlock(new HandleRef(null, hdevmode));
 }
コード例 #32
0
ファイル: DataGridExport.cs プロジェクト: rymarrv/Compas
        public static void ExportToPDF(DataGridView DataGV, string Name)
        {
            DGVEPdfExportSettings exportSettings = new DGVEPdfExportSettings();

            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            saveFileDialog1.FileName = Name;
            saveFileDialog1.DefaultExt = "pdf";
            saveFileDialog1.ShowDialog();

            exportSettings.ExportFileName = saveFileDialog1.FileName;//Export file name
            exportSettings.OpenFileAfterGeneration = true; //Open generated file after export
            System.Drawing.Printing.PaperSize paper = new System.Drawing.Printing.PaperSize("A4", 1169, 827);
            exportSettings.PdfPaperSize = paper;

            //Set other settings here...
            DGVEPdfExporter exporter = new DGVEPdfExporter();
            exporter.Export(DataGV, exportSettings);
        }