PDFInclude Barcode Code 128

davissix

New Member
I am trying to utilize and older version of PDFInclude to create a barcode. We can currently do Code 3 of 9 but cannot seem to get code 128 to work. I have code that creates a string of characters that passes to PDFInclude and I do get a barcode generated. It however does not scan. I have download a ttf and converted to an afm file.

I found a website that shows what string should look like - see attached - and I am generating that text. That text string is sent to PDFInclude and I get a barcode.

Any assistance or if anyone has sucessfully created a code 128 barcode from PDFInclude that I could talk to would be great.

I am aware there is a new version of PDFInclude available but was trying to utilize what I currently have first, if at all.

1665586045154.png
1665586087113.png
 

LarryD

Active Member
Not sure if this is what you are looking for...

Code:
/* If you have the ttf and afm, then you should be able to use this to load it */

RUN pdf_load_font("pdf","Code128"
                 ,pdf-font-dir + "code128.ttf"
                 ,pdf-font-dir + "code128.afm"
                 , "").

/* then do this to print it */
RUN  pdf_set_font ("pdf","Code128",code128_fontsize).

/* Print the bar code */
RUN pdf_text ("pdf", bc_text).

/* then reset to normal */

RUN pdf_set_Font("pdf",orig_font_name,orig_font_size).

There are other requirements for code 128 (start/stop chars and quiet zones), but that should get you started.
 
Last edited:
Hello
Code 128 requires some coding, and you can choose between 3 tables A, B and C to output the most compact code possible (else the barcode might be too wide to scan correctly, or just fit where you intend to).
Then you add the checksum, but this is the easy part ;)
You must be able to find the specifications on the internet and write your encoder. The encoder must be written for a specific code128 font, so that the glyphs in the font correspond to the "bars" the characters are meant to represent.
(full disclosure: I'm the person behind pdfInclude, so I would say purchase pdfInclude ;) which will cost less than the time you will spend on it, but your mileage may vary).
Regards
JC
PS: pdfInclude now has a new ttf font loading mecanism which does not require the afm file. Insteqd the ttf file is directly parsed and used as-is.
 
Top