简体   繁体   中英

Is it possible to preview image before printing

I am creating a check with MICR prinitng font. For the selected records from the gridview I am creating a check. Sample code is as follows

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);
}

I would like to preview before printing as per here

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

If two records are selected from gridview I would like to show them page wise. Can some one help me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM