Click here to Skip to main content
15,908,264 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am trying to generate barcode and then saving that as image, the problem is I am unable to display it in view

Below is the code in the controller
public ViewResult PrintDetails(Guid id)
        {
            ReturnedParcelList parcellist = db.ReturnedParcelLists.Single(p => p.Id == id);

            int W = 300;
            int H = 40;
            b.Alignment = BarcodeLib.AlignmentPositions.CENTER;

            b.EncodedType = BarcodeLib.TYPE.CODE128;

            b.IncludeLabel = true;


            System.Drawing.Image i= b.Encode(b.EncodedType, "IPSP10011189");

            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            i.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

           // getImg(i);

            byte[] val = ms.GetBuffer();

            ViewBag.value = val;
                  
           

            
            return View(parcellist);
        }

        public FileContentResult GetFile(byte[] id)
        {
            if (id != null)
            {
                return new FileContentResult(id, "image/jpeg");
            }

            else
            {
                return null;
            }
        }



and below is the view code where i am calling the function to display image

<img src="@Url.Action("GetFile", "ReturnedParcelLists", new { id=ViewBag.value })" alt="Image" />


but it always displaying alternate text

any help will be much appreciated and save my hours

regards
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900