Writing Barcode by Code39

Hi,
I just wanted to use Barcode. I checked manual and seen the code39.ttf and downloaded it from http://www.fonts2u.com/bar-code-39.font. I installed it on my win7 computer.

But I don't know what should I do after now.
My code is:

RUN pdf_set_font ("Spdf","Code39",10.0).
RUN pdf_text_xy ("Spdf","123123123",200,300).

But it's getting "corrupted pdf" error. Where should I save this ttf file? How can I use barcodes on my pdf file?

Regards,
Mucip:)


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Writing Barcode but can't scan?!

Hi,
I checked internet and more result here http://www.epro-sys.com/downloads/custlist.

I used below code:

RUN pdf_load_font ("Spdf","Code39","sonmezler\Raporlar\code39.ttf","sonmezler\Raporlar\code39.afm","").
/* Display a BarCode for each Customer Number */
RUN pdf_set_font ("Spdf","Code39",24.0).
RUN pdf_text_xy ("Spdf","123123123",200,300).

Yes, I see a barcode on page but can not scan it?! I loaded this code on win7 and using LibreOffice. I wrote a barcode on the page by LibreOffice but still could not scan it! Scanner is fine working I scan any barcode here except Code39?!...

What can I do?

Regards,
Mucip:)


Hi Mucip Try the following

Hi Mucip

Try the following pdf_barcode_code39 function to create a correct code39 barcode:

FUNCTION GetWidgetOption2 RETURNS CHARACTER /* PRIVATE */
(INPUT pOption AS CHARACTER,
INPUT pOptions AS CHARACTER,
INPUT pDefault AS CHARACTER):

DEFINE VARIABLE cOpt AS CHARACTER NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.

DO i = NUM-ENTRIES(pOptions) TO 1 BY -1:
cOpt = ENTRY(i, pOptions).
IF ENTRY(1, cOpt, "=") = pOption THEN
IF NUM-ENTRIES(cOpt, "=") = 1 THEN
RETURN "YES".
ELSE
RETURN ENTRY(2, cOpt, "=").
END.
RETURN pDefault.
END FUNCTION. /* GetWidgetOption2 */

FUNCTION pdf_barcode_code39 RETURNS CHARACTER (pcString AS CHARACTER, pcOptions AS CHARACTER):
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE iCheckSum AS INTEGER NO-UNDO.
DEFINE VARIABLE iIndex AS INTEGER NO-UNDO.

/* check the characters & compute check sum */
DO i = LENGTH(pcString) TO 1 BY -1:
iIndex = INDEX("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%", SUBSTRING(pcString, i, 1)).
IF iIndex = 0 THEN RETURN "".
iCheckSum = iCheckSum + iIndex - 1.
END.
iCheckSum = iCheckSum MODULO 43.
IF LOGICAL(GetWidgetOption2("Checksum", pcOptions, "YES")) THEN
pcString = pcString + SUBSTRING("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%", iCheckSum + 1, 1).

RETURN "*" + pcString + "*".
END FUNCTION.

If you call it with options "Checksum=yes" then it calculates the barcode checksum. If you do not want the checksum, call it with "Checksum=no".

regards

JC


Thanks

Dear Jc,
Thanks a lot... :)

Regards,
Mucip:)


SOLVED

Hi,
Now it's OK. I do not know but I added "*" in front of and end of string and it's OK now...

I got this information from http://www.oehive.org/node/1930

Thanks Jonathan... ;)

Regards,
Mucip:)


alonb's picture

You might want to check the

You might want to check the free docxfactory project at docxfactory.com/tutorial.

docxfactory supports practically every 1D and 2D barcode in the world, like, Code39, Code128, EAN, UPC, ISBN, Databar, Postal Codes, PDF417, Data Matrix, QR Code, Maxi Code and many more.

and you don't need to install any fonts, claculate checkdigits etc.