zoukankan      html  css  js  c++  java
  • 打印指定的区域

    Code
    public void PrintToGraphics(Graphics graphics, Rectangle bounds)
            {
                Bitmap bitmap 
    = new Bitmap(this.Width, this.Height);
                
    this.DrawToBitmap(bitmap, new Rectangle(00, bitmap.Width, bitmap.Height));
                Rectangle target 
    = new Rectangle(00, bounds.Width, bounds.Height);
                
    double xScale = (double)bitmap.Width / bounds.Width;
                
    double yScale = (double)bitmap.Height / bounds.Height;
                
    if (xScale < yScale)
                    target.Width 
    = (int)(xScale * target.Width / yScale);
                
    else
                    target.Height 
    = (int)(yScale * target.Height / xScale);
                graphics.PageUnit 
    = GraphicsUnit.Display;
                graphics.DrawImage(bitmap, target);
            }

            
    private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
            {
                PrintToGraphics(e.Graphics, e.MarginBounds);
            }

            
    private void button2_Click(object sender, EventArgs e)
            {
                
    this.printDocument1.Print();
            }

  • 相关阅读:
    bootstrap模态框
    css 禁止选中文本
    Python Flask Tornado
    JS canvas标签动态绘制图型
    JS 跳转页面
    JS 计算器
    JS
    柱状图中最大的矩形
    在不使用第三个变量的情况下交换两个数的值
    springboot配置静态资源访问的2种方式
  • 原文地址:https://www.cnblogs.com/shineqiujuan/p/1606935.html
Copyright © 2011-2022 走看看