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.
 

jvergara

New Member
Hola
El código 128 requiere algo de codificación y puede elegir entre 3 tablas A, B y C para generar el código más compacto posible (de lo contrario, el código de barras podría ser demasiado ancho para escanearlo correctamente o simplemente caber donde desea).
Luego agregas la suma de verificación, pero esta es la parte fácil.;)
Debe poder encontrar las especificaciones en Internet y escribir su codificador. El codificador debe escribirse para una fuente code128 específica, de modo que los glifos en la fuente correspondan a las "barras" que los caracteres deben representar.
(divulgación completa: soy la persona detrás de pdfInclude, por lo que diría que compre pdfInclude, ;) que costará menos que el tiempo que dedicará a él, pero su kilometraje puede variar).
Saludos
jc
PD: pdfInclude ahora tiene un nuevo mecanismo de carga de fuentes ttf que no requiere el archivo afm. En su lugar, el archivo ttf se analiza directamente y se utiliza tal cual.
 
Top