0

I'm trying to create a barcode image that I could then upload to a database. I've been trying to fix this for days now, and I just don't seem to get it. code128.CreateDrawingImage takes 2 arguments which are System.Drawing.Color for fore and background, but when I add those, it tells me that it "Cannot implicitly convert type System.Drawing.Image to iTextSharp.text.image"

// Create barcode
 Barcode128 code128 = new Barcode128();
 code128.CodeType = Barcode.CODE128_UCC;
code128.Code = "123456789";
// Generetate barcode img
iTextSharp.text.Image img128 = code128.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White);
Pauli
  • 149
  • 4
  • 13
  • Have you tried typecasting it? ... = (Image) code128.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White); ? – gleng Oct 17 '13 at 11:47
  • Yes, I tried typecasting to iTextSharp Image, but I says that it can't convert drawing image to itextsharp image :( – Pauli Oct 17 '13 at 11:52
  • Try this link: http://stackoverflow.com/questions/12194572/set-barcode-128-to-type-b-in-java – gleng Oct 17 '13 at 12:06
  • That actually probably solved it! – Pauli Oct 17 '13 at 12:17
  • Have you looked into the documentation for iTextSharp on setting the Image? – gleng Oct 17 '13 at 12:17
  • Yeah, I tried to look at them. But your link fixed it. With a little modification to the code I was able to create an barcode image! Thanks ! – Pauli Oct 17 '13 at 12:22
  • I am trying to do something similar, but the image is 12x12, have you been able to resize the barcode image? – reckface Oct 24 '13 at 14:50
  • I only got the default size. Which wasn't too big unfortunately. also I didn't have a barcode reader except for an app for iphone, but with that I was unable to even read the barcode. I don't know if it was because of the quality or just wrong type of barcode for the app. – Pauli Oct 30 '13 at 20:02

0 Answers0