Creating a DataMatrix GS1 barcode and saving to postscript, PDF, or image for free in C#.

I’ve been working on an interesting project where I had to learn Pitney Bowes Streamweaver in order to sort/merge and barcode postscript. I have very little knowledge of postscript and no training or knowledge of Streamweaver whatsoever.

I rolled my own in C# in order to understand how the product worked for parsing but didn’t know much about creating the data matrix barcode and placing it into the postscript, which left me relying on Streamweaver no matter what.

My employer is continuing to use Streamweaver until we rewrite this functionality into Adobe ES (hopefully) but if you have small amounts of postscripts to barcode for printing or whatever maybe this will be helpful. Adobe has a free book to get you up to speed on the Postscript language and this post was helpful as well.

I wrote a small console app that will produce a barcode written out in Postscript, JPG, PDF, Hex and ASCII85 encoded. This program has few features and less options as I was just playing with different approaches, these turned out to be the best, but if you need more just ask and I can help as much as possible.

barcode

Download DataMatrix Barcode Generator

Before I go further I’d like to acknowledge and link the folks who did the real work!

Datamatrix.Net
Ghostscript
Ghostscript.Net
iTextSharp
Ascii85 encoding code

Here’s a sample of the code.

C#

Some conversions in Python.

Python

Adding jpeg hex to an Adobe postscript. You should be able to paste this into an existing postscript, just be careful where you place it; directly after %%Page might be a good start.

Plain Text

If you need to convert XML to PostScript check out this excellent tool from Apache:

https://xmlgraphics.apache.org/fop/