首页 > 编程 > C# > 正文

C#打印绘图的实现方法

2019-10-29 21:43:33
字体:
来源:转载
供稿:网友
这篇文章主要介绍了C#打印绘图的实现方法,涉及C#针对图片的绘制与打印相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下
 

本文实例讲述了C#打印绘图的实现方法。分享给大家供大家参考。具体实现方法如下:

 

复制代码代码如下:

String drawString = "";
Font drawFont = null;
SolidBrush drawBrush = null;
float x = 0F;
float y = 0F;
StringFormat drawFormat = new StringFormat();

 

string test = "";

public string Test
{
    get { return test; }
    set { test = value; }
}
public Form1()
{
    InitializeComponent();
    //设置纸张大小
    PaperSize paperSize = new PaperSize("DataOrder", 1023, 614);
    printDocument1.DefaultPageSettings.PaperSize = paperSize;
}

//打印
private void button1_Click(object sender, EventArgs e)
{
    printDocument1.PrintPage += new PrintPageEventHandler(MyPrintDoc_PrintPage);
    try
    {
 printPreviewDialog1.Document = printDocument1;
 printPreviewDialog1.FormBorderStyle = FormBorderStyle.Fixed3D;
 printPreviewDialog1.ShowDialog();
 printDocument1.Print();
    }
    catch
    {

 MessageBox.Show("请安装打印机", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
}

protected void MyPrintDoc_PrintPage(object sender, PrintPageEventArgs e)
{
    //字体 颜色 格式 坐标
    drawFont = new Font("Arial", 8);
    drawBrush = new SolidBrush(Color.Black);
    x = 0F;
    y = 0F;
    drawFormat.FormatFlags = StringFormatFlags.NoWrap;

    //块数
    int num = 6;
    float weightAll = 12.600F;
    //标题
    //标题第一行
    string src="/uploads/allimg/150125/12463344G-0.jpg?2015020103929" style="border: 1px solid rgb(204, 204, 204); padding: 3px; max-width: 620px; overflow: hidden;" />

希望本文所述对大家的C#程序设计有所帮助。


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表