Code Monkey home page Code Monkey logo

crystalreports-code128's Introduction

Bar code 128 in Crystal Report

To have Code 128 barcode in report from CR you have 2 options:

  1. Create or use a UFL class library - nice but you need to install additional files into CR runtime directory, and the code 128 font.
  2. Use a font file and function that returns code 128 formatted string, that you can display it in text object with set font to Code 128. Much simpler, only need to instal Code128 font which is done by very simply in Win7/Win10 already (just open file and click install in font preview dialog).

I decided to go with option 2 which is much easier to implement (still re-writing code that works in CR was PITA ๐Ÿ˜… ).

I have rewritten code from page: https://grandzebu.net/informatique/codbar-en/code128.htm#Version which is a gold mine for barcode symbologies information.

Pre-reqs

Download from mentioned page the font file ( look for paragraph: The font " code128.ttf " ). Open the downloaded font file, make sure that in window you have Version: 2.0 and then click Install in window. (I am including the font file Code128.ttf v.2.0 in case Grandzebu webpage would gone offline).

Define functions

In Crystal Reports Formula Workshop, create new Custom function name it MyBarcode128. Switch syntax to Basic syntax and paste into window content of the text file: MyBarcode128.txt .

Click Save and close - if displays an error - I can't help much, I have it working in CR 2019 (in VS extension).

Usage

Place a text object (unbound string field), open it's properties (Format object).

Set Font to Code128, set the font size (I think size about 18-32pt should result in big enough barcode but not too big for most printers).

Edit formula of the object.

You will see Formula Workshop window. Switch to Crystal syntax (I don't know why it won't work in Basic syntax ๐Ÿค” ). Just type function name MyBarcode128("THE-CODE-CONTENT-"), or drag into the parenthesis field from Fields.

Now just Save and close and you can enjoy barcodes in Code 128 on your report.

Preview

(Barcode Scanner app on Android)

End notes

If you stumble upon squares in your code ( issue #1 - printing problem ) then you need to use common encoding font (I'm not going into depths about it and what it means - I'm just not interested in it - as long as works ๐Ÿ˜„ ), just use simchev code, avaiable at his repo: https://github.com/simchev/crystalreports-code128 .

Credits

All the most important work came from Grandzebu https://grandzebu.net/. If you find it usefull give him a small donation for his work (you can find link to it at end of page with code description). As for me, I'll be fine if you keep link to my repo in function comment ๐Ÿ˜„

EOF

crystalreports-code128's People

Contributors

saper-2 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.