是否可以在打印前预览图像

时间:2012-08-14 08:52:41

标签: c# asp.net printing

我正在使用MICR prinitng字体创建支票。对于gridview中的选定记录,我正在创建一个检查。示例代码如下

public void print()
{
    try
    {
        PrivateFontCollection PFC = new PrivateFontCollection();
        PFC.AddFontFile(Server.MapPath("ADVMICR.TTF"));
        FontFamily fm = new FontFamily(PFC.Families[0].Name, PFC);
        Font PrintFont = new Font(fm, 12);

        PrintDocument pd = new PrintDocument();
        pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
        //Specify the printer to use.  HP LaserJet P2035
        pd.PrinterSettings.PrinterName = "HP LaserJet P2035";
        pd.Print();
    }
    catch (Exception Ee)
    {

    }
}

public void pd_PrintPage(object sender, PrintPageEventArgs e)
{
       e.Graphics.DrawString("PAY TO THE ORDER OF", drFont, drawBrush, 15.0F, 120.0F);
        e.Graphics.DrawString(FirstName + "," + MiddleInitial + ":" + LastName, drnarrowFont1, drawBrush, 145.0F, 117.0F);
        e.Graphics.DrawString(CompanyName, drarialblackFont, drawBrush, 140.0F, 30.0F);
        e.Graphics.DrawString(Address1, drsmallFont, drawBrush, 140.0F, 45.0F);
        e.Graphics.DrawString(City + "," + StateName, drsmallFont, drawBrush, 140.0F, 55.0F);
        e.Graphics.DrawString(Country + "," + ZipCode, drsmallFont, drawBrush, 140.0F, 69.0F);
        e.Graphics.DrawString("DATE", drFont, drawBrush, 595.0F, 70.0F);
        e.Graphics.DrawString(strDateTime, drnarrowFont, drawBrush, 650.0F, 65.0F);
        e.Graphics.DrawString("MEMO", drFont, drawBrush, 15.0F, 262.0F);
        e.Graphics.DrawString(iCheckno.ToString().PadLeft(4, (char)48), drFont, drawBrush, 730.0F, 20.0F);
        e.Graphics.DrawString(strFractionCode1, drnarrowFont, drawBrush, 720.0F, 40.0F);
        e.Graphics.DrawString("DOLLARS", drFont, drawBrush, 700.0F, 170.0F);
}

我想在打印之前预览

http://projects.erikzaadi.com/jQueryPlugins/jQuery.printElement/

如果从gridview中选择了两个记录,我想以页面方式显示它们。有人能帮我吗。