Writing Barcode...

Discussions about barcode reading and writing
Post Reply
mdelbene
Posts: 31
Joined: Wed May 11, 2011 10:03 am

Writing Barcode...

Post by mdelbene » Wed Jun 08, 2011 3:54 pm

Hi all,
I'm exploring Barcode features and I'd like to write a barcode including the numbers on the bottom of the image.

I create the image with the method oGdPictureImaging.Barcode1DWrite, and I show it in GdViewer area, but I didn't find the way to include also the numbers...
I tried to use all the available Barcode1DWriterType, but nothing, the numbers don't appear. :cry:

Anyone can help me?
Thanks in advance.
Michela

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Writing Barcode...

Post by Loïc » Wed Jun 08, 2011 4:30 pm

Hi Michela,

The Barcode1DWrite function draws only the barcode shape. If you want to draw its content you have to use the DrawText method subsequently.


Hope this helps.

Loïc

mdelbene
Posts: 31
Joined: Wed May 11, 2011 10:03 am

Re: Writing Barcode...

Post by mdelbene » Wed Jun 08, 2011 5:00 pm

Thank you Loïc,
with DrawText method now I can see my numbers! :)

Now I have a GdViewer that contains the barcode.
Next step is to read this barcode from the GdViewer area and read its information contained in it.

I get ideas from SDK samples and I'm trying to use oGdPictureImaging.Barcode1DReaderDoScan method.
The GdPictureStatus is OK, but when I call oGdPictureImaging.Barcode1DReaderGetBarcodeCount no barcode is found.

In your sample the barcode is read from a file, I tried to simulate this behaviour saving first the image in a file and next loading, but the barcode is not recognized.

Have you another suggestion for me?

Thanks a lot.
Michela

mdelbene
Posts: 31
Joined: Wed May 11, 2011 10:03 am

Re: Writing Barcode...

Post by mdelbene » Fri Jul 01, 2011 4:28 pm

Hi all,
two days ago my company bought the upgrade to new version 8 and now I'm trying to upgrade my application.

I encountered an error while I'm trying to write a Barcode.
This is the code snippet:

Code: Select all

	private void BCButton_Click(object sender, EventArgs e)
		{
			GdPictureStatus status = GdPictureStatus.GenericError;

			try
			{
				// Crea una GdPicture Image vuota
				int imageId = gdPicture.CreateNewGdPictureImage(250, 100, PixelFormat.Format24bppRgb, Color.White);

				if (imageId > 0)
				{
					// write barcode in new image
					status = gdPicture.Barcode1DWrite
						(
							imageId,
							Barcode1DWriterType.Barcode1DWriterCode39,
							"TEST-12345",
							0, 
							0, 
							250,
							80, 
							Color.Black,
							BarcodeAlign.BarcodeAlignCenter
						);

					if (status == GdPictureStatus.OK)
					{
						status = gdPicture.Barcode1DReaderDoScan(imageId);
						string bcValue = string.Empty;

						if (status == GdPictureStatus.OK)
						{
							for (int i = 1; i <= gdPicture.Barcode1DReaderGetBarcodeCount(); i++)
								bcValue = gdPicture.Barcode1DReaderGetBarcodeValue(i);

							gdPicture.Barcode1DReaderClear();
						}

						// now I add a text with barcode value
						if (bcValue != null && !string.IsNullOrWhiteSpace(bcValue))
							status = gdPicture.DrawText
								(
								imageId,
								bcValue,
								40,
								80, 
								8, 
								GdPicture.FontStyle.FontStyleRegular,
								Color.Black,
								"Verdana",
								true 
								);

						if (status == GdPictureStatus.OK)
							status = this.GdViewer1.DisplayFromGdPictureImage(imageId);
					}
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
				System.Diagnostics.Debug.WriteLine(ex.Message);
			}
		}
So when I use the method Barcode1DWrite, the program throws an exception with this message:
Could not load type 'GdPicture.NET.Barcode.Writer.Barcode' from assembly 'GdPicture.NET.barcode.1d.writer, Version=2.0.0.0, Culture=neutral, PublicKeyToken=e8bb32f622d7e512'.

I'm using the new dlls of version 8 downloaded from this site and also I've updated my project references.

Anyone can help me?
Thanks in advance.
Michela

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Writing Barcode...

Post by Loïc » Fri Jul 01, 2011 10:14 pm

Hi Michela,

I think you are still linking the previous version of the 1D barcode writer.

What I can suggest is to ensure yourself to fully uninstall GdPicture.NET 7 from your computer, then install again the V8. I'm pretty sure this should solve your problem.

Kind regards,

Loïc

mdelbene
Posts: 31
Joined: Wed May 11, 2011 10:03 am

Re: Writing Barcode...

Post by mdelbene » Mon Jul 04, 2011 10:55 am

Hi Loïc,
you are right.
After uninstall GdPicture v. 7.4 my Barcode appears! :)

Thanks for your support.
Michela

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest