locked
barcode image created, how can i use the finish image? RRS feed

  • Question

  • User-1665560158 posted

    Thanks in advance!  

    Hello, i found the code below it works correctly using  barcode.asp?id=123. Now I need to place the image created in a "packing slip" or pack.aspx. the image created is located in location x 10 and y 10 from the page(barcode.aspx). if this is a form with more information and i want to place the image at the middle of the page with an asp:image how is this accomplished?

     

    using System;

    using System.Collections;

    using System.Configuration;

    using System.Data;

    using System.Linq;

    using System.Drawing;

    using System.Drawing.Text;

    using System.IO;

    using System.Drawing.Imaging;

    using System.Web;

    using System.Web.Security;

    using System.Web.UI;

    using System.Web.UI.HtmlControls;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

    using System.Xml.Linq;

    namespace IMS_2K9.Barcode

    {

    public partial class Barcode : System.Web.UI.Page

    {

    protected void Page_Load(object sender, EventArgs e)

    {

    //Settings for the Image

    string TypeFaceName = "barcode font";

    //This is the information that has to be barcoded

    string txt = Request.QueryString["id"].ToString();

    //The format of the image file

    ImageFormat format = ImageFormat.Jpeg;

    //path of unique file name

    string path = txt+".jpg";

    //REFERENCING A FONT

    PrivateFontCollection fnts = new PrivateFontCollection();

    fnts.AddFontFile("BarcodeFont.ttf");

    FontFamily fntfam = new FontFamily(TypeFaceName, fnts);

    Font fnt = new Font(fntfam, 50);

    //DRAWING THE IMAGE

    Bitmap bmp = new Bitmap(160, 160); //Canvas size

    Graphics g = Graphics.FromImage(bmp);

    g.Clear(Color.White); //Background color

    SizeF bc = g.MeasureString(txt, fnt);

    Brush br = new SolidBrush(Color.Black);

    g.DrawString(txt, fnt, br, 10, 10); //Drawing the Image

    bmp.Save(Server.MapPath(path), format); //Saving the Image file

    bmp.Dispose(); //Releasing all resources (Image file)

    Response.Clear();

     

    //YOUR IMAGE DELIVERY CODE GOES HERE

    Response.TransmitFile(path);

    Response.Flush();

    // Image1.ImageUrl = path; this does not work... 

     Response.End();

    }

    }

    }

    Monday, January 12, 2009 2:26 PM

Answers

  • User437720957 posted

     <asp:Image id="something" runat="server" ImageUrl="barcode.aspx?id=123"/>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 12, 2009 3:23 PM

All replies

  • User437720957 posted

     <asp:Image id="something" runat="server" ImageUrl="barcode.aspx?id=123"/>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 12, 2009 3:23 PM
  • User-1665560158 posted

    Thanks, i didn't know i could refer to an image in such a way... Thanks for your feedback!!

    Monday, January 12, 2009 4:24 PM