I've been using your product and it's great. I was very impressed that you even included bar code capabilities which is what I was looking for. Up until recently, all I needed was 3 of 9 capabilities. Now, However, I need to be able to use a barcode that handles upper case, lower case, numeric, and some of the basic symbols (+(plus sign) and /(slash)). I believe what I would need is barcode 128. Is there any plans to add this in the near future or do you know a way I can incorporate this into the product.

With a little direction, I might be able to code it myself and I would be more than happy to share it so it could be included in a future release.

In the PdfSharp project under PdfSharp.Drawing.BarCodes, there's a missing text document: @BarCodes.txt. Is there any information in there that would help me move forward with my project? If so, could I be sent a copy of it?

// Create the array to hold the values to be rendered if (Code128Code == Code_128_Code_Types.CodeC) { // Ensure that the text is an even length if ((text.Length % 2) == 1) throw new ArgumentOutOfRangeException("Parameter text (string) must have an even length for Code 128 - Code C"); Values = new byte[text.Length / 2]; } else { Values = new byte[text.Length]; }

private void CheckValues() { if (Values == null) throw new InvalidOperationException("Text or Values must be set"); if (Values.Length == 0) throw new InvalidOperationException("Text or Values must have content");

private byte[] GetPattern(int codeValue) { if (codeValue < 0) throw new ArgumentOutOfRangeException("Parameter ch (int) can not be less than 32 (space)."); if (codeValue > 106) throw new ArgumentOutOfRangeException("Parameter ch (int) can not be greater than 138."); return Patterns[(byte)codeValue]; }

/// <summary>Renders a single line of the character. Each character has three lines and three spaces</summary> /// <param name="info"></param> /// <param name="barWidth">Indicates the thickness of the line/bar to be rendered.</param> internal void RenderBar(BarCodeRenderInfo info, double barWidth) { RenderBar(info, barWidth, info.Brush); }

/// <summary>Renders a single line of the character. Each character has three lines and three spaces</summary> /// <param name="info"></param> /// <param name="barWidth">Indicates the thickness of the line/bar to be rendered.</param> /// <param name="brush">Indicates the brush to use to render the line/bar.</param> private void RenderBar(BarCodeRenderInfo info, double barWidth, XBrush brush) { double height = Size.Height; double yPos = info.CurrPos.Y;

int numberOfBars = Values.Length + 3; // The length of the string plus the start, stop, and parity value numberOfBars *= 11; // Each character has 11 bars numberOfBars += 2; // Add two more because the stop bit has two extra bars

Here's a quick example on how to use it. 1. Create a console application in visual studio2. Add your new PdfSharp library as a reference3. Replace the contents of your 'program.cs' file with the following:

throw new ArgumentOutOfRangeException("Parameter text (string) must have an even length for Code 128 - Code C");...throw new ArgumentOutOfRangeException("Parameter text (string) can only contain numeric characters for Code 128 - Code C");

These are both invalid, and I suspect several of your other throws are invalid too. Code128 can encode all 128 low-ASCII characters, and it's the encoder's responsibility to shift/switch between A, B, and C as necessary to make that happen; you seem to be ignoring this entirely.

To produce the shortest possible barcode:Switch to 128C (or start in 128C) when you encounter four consecutive digits. (There are situations where using 128C for two digits, or 128A/B for four digits, will produce an equally short barcode, but neither can ever produce a shorter barcode.)Start A/B, Switch A/B, and Shift A/B are more complicated.Temporarily drop all characters that can be encoded in both 128A and 128B.If no characters remain, pick one at random.If you are switching from C to A/B, look at the first remaining character and use the subcode that can encode it.If you are considering switching A<->B, look all the remaining characters and seek forward until you find two or three (I haven't figured that one out yet) consecutive characters (remember that these consecutive characters may not be consecutive in the original string) that are both 128A-only or 128B-only. Use that subcode until there, shifting (entity 98) as necessaryIf you are starting in A or B, do as above, but it's definitely two consecutive characters.

Last edited by DaleStan on Tue Mar 16, 2010 3:35 pm, edited 1 time in total.

Hello, I have issue with that solution. I've added this patch, but unfortunately when I'm trying to add barcode (128) it appears with embedded text (which is correct and as expected), but code after scanning is "123123". Constructor in BarcodeRenderer.cs contains this value - but as far I have no idea how to fix it.

Any help would be appreciated

[Edit:] Of course it was matter of constructor in render method in BarcodeRenderer.cs - I should have look more carefully. Great solution for Barcode 128, thanks

These are both invalid, and I suspect several of your other throws are invalid too. Code128 can encode all 128 low-ASCII characters, and it's the encoder's responsibility to shift/switch between A, B, and C as necessary to make that happen; you seem to be ignoring this entirely.

Who is online

Users browsing this forum: No registered users and 3 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum