C#PrintDocument列印尺寸調整

來源:互聯網
上載者:User

標籤:需要   alt   tle   vat   log   custom   oid   入庫   family   

 /// <summary>        /// 列印的按鈕        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void btnPrint_Click(object sender, EventArgs e)        {            // printDocument1 為 列印控制項            //設定列印用的紙張 當設定為Custom的時候,可以自訂紙張的大小,還可以選擇A4,A5等常用紙型            this.printDocument1.DefaultPageSettings.PaperSize = new PaperSize("Custom",500,300);                       this.printDocument1.PrintPage += new PrintPageEventHandler(this.MyPrintDocument_PrintPage);            //將寫好的格式給預覽列印控制項以便預覽            printPreviewDialog1.Document = printDocument1;            //顯示預覽列印            DialogResult result = printPreviewDialog1.ShowDialog();        }        /// <summary>        /// 列印的格式        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void MyPrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)        {            /*如果需要改變自己 可以在new Font(new FontFamily("黑體"),11)中的“黑體”改成自己要的字型就行了,黑體 後面的數字代表字型的大小             System.Drawing.Brushes.Blue , 170, 10 中的 System.Drawing.Brushes.Blue 為顏色,後面的為輸出的位置 */            e.Graphics.DrawString("新鄉市三月軟體公司入庫單", new Font(new FontFamily("黑體"), 11), System.Drawing.Brushes.Black, 170, 10);            e.Graphics.DrawString("供貨商:河南科技學院", new Font(new FontFamily("黑體"), 8), System.Drawing.Brushes.Blue, 10, 12);            //資訊的名稱            e.Graphics.DrawLine(Pens.Black, 8, 30, 480, 30);            e.Graphics.DrawString("入庫單編號", new Font(new FontFamily("黑體"), 8), System.Drawing.Brushes.Black, 9, 35);            e.Graphics.DrawString("商品名稱", new Font(new FontFamily("黑體"), 8), System.Drawing.Brushes.Black, 160, 35);            e.Graphics.DrawString("數量", new Font(new FontFamily("黑體"), 8), System.Drawing.Brushes.Black, 260, 35);            e.Graphics.DrawString("單價", new Font(new FontFamily("黑體"), 8), System.Drawing.Brushes.Black, 330, 35);            e.Graphics.DrawString("總金額", new Font(new FontFamily("黑體"), 8), System.Drawing.Brushes.Black, 400, 35);            e.Graphics.DrawLine(Pens.Black, 8, 50, 480, 50);            //產品資訊            e.Graphics.DrawString("R2011-01-2016:06:35", new Font(new FontFamily("黑體"), 8), System.Drawing.Brushes.Black, 9, 55);            e.Graphics.DrawString("聯想A460", new Font(new FontFamily("黑體"), 8), System.Drawing.Brushes.Black, 160, 55);            e.Graphics.DrawString("100", new Font(new FontFamily("黑體"), 8), System.Drawing.Brushes.Black, 260, 55);            e.Graphics.DrawString("200.00", new Font(new FontFamily("黑體"), 8), System.Drawing.Brushes.Black, 330, 55);            e.Graphics.DrawString("20000.00", new Font(new FontFamily("黑體"), 8), System.Drawing.Brushes.Black, 400, 55);            e.Graphics.DrawLine(Pens.Black, 8, 200, 480, 200);            e.Graphics.DrawString("地址:新鄉市河南科技學院資訊工程學院", new Font(new FontFamily("黑體"), 8), System.Drawing.Brushes.Black, 9, 210);            e.Graphics.DrawString("經辦人:任忌", new Font(new FontFamily("黑體"), 8), System.Drawing.Brushes.Black, 220, 210);            e.Graphics.DrawString("服務熱線:15083128577", new Font(new FontFamily("黑體"), 8), System.Drawing.Brushes.Black, 320, 210);            e.Graphics.DrawString("入庫時間:" + DateTime.Now.ToString(), new Font(new FontFamily("黑體"), 8), System.Drawing.Brushes.Black, 9, 230);        }

C#PrintDocument列印尺寸調整

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.