Recent

Author Topic: Generate barcode, help  (Read 6140 times)

criss6100

  • New Member
  • *
  • Posts: 24
Generate barcode, help
« on: January 27, 2015, 10:31:38 pm »
I have developed an application for sorting books and I need a simple code to generate a barcode that can be printed on the books
What I would like is when I press a button eg: "generate code" a image of the barcode to be displayed on screen in the main app window
I tried with barcodes.pas but I cannot find any documentation on how to use the unit, same for LazBarcodes
Can someone please shed some light on this, any kind of help is apeciated

Thank you :)

tudi_x

  • Hero Member
  • *****
  • Posts: 532
Re: Generate barcode, help
« Reply #1 on: January 28, 2015, 12:04:19 am »
In case you can use something else I would suggest fpdf library.
I am using fpdf that was adapted to Lazarus - open source (I do not remember now how I got the library).
Documentation you can find at from http://www.fpdf.org/.
It has a code 25 bar code capability I am using with no issues.
Lazarus 2.0.2 64b on Debian LXDE 10

tudi_x

  • Hero Member
  • *****
  • Posts: 532
Re: Generate barcode, help
« Reply #2 on: January 28, 2015, 12:11:43 am »
Lazarus 2.0.2 64b on Debian LXDE 10

paweld

  • Hero Member
  • *****
  • Posts: 991
Best regards / Pozdrawiam
paweld

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Generate barcode, help
« Reply #4 on: January 28, 2015, 02:32:39 am »
The barcode unit that comes with Lazarus is quite self-explanatory.

Simply create a barcode object from TBarcode class with

Code: [Select]
theBarCode := TBarcode.Create(self);
and modify its properties as required. The most important ones are Typ that should be set to one of bcCode_2_5_interleaved, bcCode_2_5_industrial, bcCode_2_5_matrix, bcCode39, bcCode39Extended, bcCode128A, bcCode128B, bcCode128C, bcCode93, bcCode93Extended, bcCodeMSI, bcCodePostNet, bcCodeCodabar, bcCodeEAN8 or bcCodeEAN13 (see http://en.wikipedia.org/wiki/Barcode for an explanation) and position and size defined by the top, left and height properties.

Pass the content to be encoded with the text property. This causes TBarcode to convert this string to a barcode image. This image is placed with DrawBarcode on the specified canvas.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Generate barcode, help
« Reply #5 on: January 28, 2015, 05:26:52 am »
Why not use the ISBN numbers that are already printed on your books?

criss6100

  • New Member
  • *
  • Posts: 24
Re: Generate barcode, help
« Reply #6 on: January 28, 2015, 05:52:36 pm »
Tank you all for the tips, I finally managed to get it working :)

 

TinyPortal © 2005-2018