MAJOR Barcode issues in C1Report/C1PDF.

Posted by: therealtkd on 10 September 2017, 11:51 am EST

  • Posted 10 September 2017, 11:51 am EST

    I have a client with a Silverlight application. They request a report which has Code39 barcodes on it. The report is generated on the server, saved to PDF and the resulting PDF is streamed back to the client who views it in Acrobat Reader. The PDF can then be printed to either an A4 printer or a Zebra label printer.

    I was on an old version of the C1Components and the barcodes printed acceptably and could be scanned. However, I have recently upgraded the C1Components and now its all stuffed. I have a very upset client!

    I am using C1.C1Pdf.4 (4.1.20122.205 v4.0.30319) and C1.C1Report.4 (4.6.20122.54513 v4.0.30319)

    I have attached an image showing issues. The ruler shows the barcodes to scale.

    A. The barcode printed at a large size to A4 on an inkjet. It scans ok.

    B. Barcode printed at smaller size. This is the size required to fit on the labels being used by the labels. This is printed on an A4 printer. There doesn't seem to be enough separation between the bars. In the old version the lines were not as heavy and it scanned acceptable.

    C and D. These are printed on the Zebra label printer. I believe the bars print with an acceptable
    clarity but the bars are different widths. This is the same report printed twice, so I would expect the same result. But look at the circled areas. The bars and spacing between are different thicknesses!!!!! How can that be?

    At this stage I am going to have to try to go back to an earlier version of the components.

    There are other issues with barcodes as well but I have a time constraint so will have to log later. Just wanted to get this issue raised ASAP!!!

  • Replied 10 September 2017, 11:51 am EST

    Exactly how do you export your report to PDF? C1Report supports export to PDF internally hence I'm not sure why you mention C1Pdf hence my question.
  • Replied 10 September 2017, 11:51 am EST

    report.RenderToFile(fileName, FileFormatEnum.PDF);

    The C1.C1PDF is actually usedfor some otherstuff. So it is just teh C1.C1Report that is being used in this particular case.
  • Replied 10 September 2017, 11:51 am EST

    Also the report is not imported from an XML file. It is built within the program.

    field = section.Fields.Add("Fld" + rowCount.ToString(), "",
    (double)labelDtl.MarginLeft * MEASURE,
    (double)labelDtl.MarginTop * MEASURE,
    (double)labelDtl.ItemWidth * MEASURE,
    (double)labelDtl.ItemHeight * MEASURE);

    // set up the font details
    field.Font.Name = labelDtl.FontName;
    if ((float)labelDtl.FontSize > 0)
    field.Font.Size = (float)labelDtl.FontSize;
    field.Font.Bold = labelDtl.FontBold;
    field.Font.Italic = labelDtl.FontItalic;
    //field.Font.Underline = (reader.GetByte(reader.GetOrdinal("UNDERLINE")) == 1);
    field.WordWrap = true;

    // work out the alignment
    switch (labelDtl.HorizontalAlignment)
    {
    case 0 : // left alignment
    switch (labelDtl.VerticalAlignment)
    {
    case 0 : field.Align = FieldAlignEnum.LeftTop; break;
    case 1 : field.Align = FieldAlignEnum.LeftMiddle; break;
    case 2 : field.Align = FieldAlignEnum.LeftBottom; break;
    }
    break;
    case 1 : // centre alignment
    switch (labelDtl.VerticalAlignment)
    {
    case 0 : field.Align = FieldAlignEnum.CenterTop; break;
    case 1 : field.Align = FieldAlignEnum.CenterMiddle; break;
    case 2 : field.Align = FieldAlignEnum.CenterBottom; break;
    }
    break;
    case 2 : // right alignment
    switch (labelDtl.VerticalAlignment)
    {
    case 0 : field.Align = FieldAlignEnum.RightTop; break;
    case 1 : field.Align = FieldAlignEnum.RightMiddle; break;
    case 2 : field.Align = FieldAlignEnum.RightBottom; break;
    }
    break;
    default :
    field.Align = FieldAlignEnum.LeftTop;
    break;
    }

    field.ForeColor = SRConversions.IntToColor(labelDtl.ForegroundColour);
    field.BackColor = SRConversions.IntToColor(labelDtl.BackgroundColour);

    // if this is a field then it needs to be calculated, otherwise its a label and we just want to
    // display the actual text
    if (labelDtl.Type == "LABEL")
    field.Text = CalcFieldName(labelDtl.LabelText);

    if (labelDtl.Type == "DATA")
    {
    field.Text = CalcFieldName(labelDtl.LabelDataField);
    if (field.Text == "Barcode")
    field.BarCode = BarCodeEnum.Ean13;
    if (field.Text == "BarcodeIPN")
    field.BarCode = BarCodeEnum.Code39;
    field.Format = CalcFormat(labelDtl.LabelDataField);
    field.PictureScale = PictureScaleEnum.Stretch; <-------- HERE
    field.Calculated = true;
    }


    Note the PictureScale property beign set for barcodes? That used to allow the barcode to be scaled. That doesn't work anymore either. It now prints to a fixed width and if the label field is not wide enough it simply truncates the bars on the barcode.

    That was the initial problem for the client. I asked them to change the label design so the barcode was wider. The bars all display now but still doesn't scan because, I suspect, of the different widths of the bars and spacing I originally reported above.
  • Replied 10 September 2017, 11:51 am EST

    Also the report is not imported from an XML file. It is built within the program.

    field = section.Fields.Add("Fld" + rowCount.ToString(), "",
    (double)labelDtl.MarginLeft * MEASURE,
    (double)labelDtl.MarginTop * MEASURE,
    (double)labelDtl.ItemWidth * MEASURE,
    (double)labelDtl.ItemHeight * MEASURE);

    // set up the font details
    field.Font.Name = labelDtl.FontName;
    if ((float)labelDtl.FontSize > 0)
    field.Font.Size = (float)labelDtl.FontSize;
    field.Font.Bold = labelDtl.FontBold;
    field.Font.Italic = labelDtl.FontItalic;
    //field.Font.Underline = (reader.GetByte(reader.GetOrdinal("UNDERLINE")) == 1);
    field.WordWrap = true;

    // work out the alignment
    switch (labelDtl.HorizontalAlignment)
    {
    case 0 : // left alignment
    switch (labelDtl.VerticalAlignment)
    {
    case 0 : field.Align = FieldAlignEnum.LeftTop; break;
    case 1 : field.Align = FieldAlignEnum.LeftMiddle; break;
    case 2 : field.Align = FieldAlignEnum.LeftBottom; break;
    }
    break;
    case 1 : // centre alignment
    switch (labelDtl.VerticalAlignment)
    {
    case 0 : field.Align = FieldAlignEnum.CenterTop; break;
    case 1 : field.Align = FieldAlignEnum.CenterMiddle; break;
    case 2 : field.Align = FieldAlignEnum.CenterBottom; break;
    }
    break;
    case 2 : // right alignment
    switch (labelDtl.VerticalAlignment)
    {
    case 0 : field.Align = FieldAlignEnum.RightTop; break;
    case 1 : field.Align = FieldAlignEnum.RightMiddle; break;
    case 2 : field.Align = FieldAlignEnum.RightBottom; break;
    }
    break;
    default :
    field.Align = FieldAlignEnum.LeftTop;
    break;
    }

    field.ForeColor = SRConversions.IntToColor(labelDtl.ForegroundColour);
    field.BackColor = SRConversions.IntToColor(labelDtl.BackgroundColour);

    // if this is a field then it needs to be calculated, otherwise its a label and we just want to
    // display the actual text
    if (labelDtl.Type == "LABEL")
    field.Text = CalcFieldName(labelDtl.LabelText);

    if (labelDtl.Type == "DATA")
    {
    field.Text = CalcFieldName(labelDtl.LabelDataField);
    if (field.Text == "Barcode")
    field.BarCode = BarCodeEnum.Ean13;
    if (field.Text == "BarcodeIPN")
    field.BarCode = BarCodeEnum.Code39;
    field.Format = CalcFormat(labelDtl.LabelDataField);
    field.PictureScale = PictureScaleEnum.Stretch; <-------- HERE
    field.Calculated = true;
    }


    Note the PictureScale property beign set for barcodes? That used to allow the barcode to be scaled. That doesn't work anymore either. It now prints to a fixed width and if the label field is not wide enough it simply truncates the bars on the barcode.

    That was the initial problem for the client. I asked them to change the label design so the barcode was wider. The bars all display now but still doesn't scan because, I suspect, of the different widths of the bars and spacing I originally reported above.
  • Replied 10 September 2017, 11:51 am EST

    I went back to the original C1.C1Report.2.dll ( 2.6.20093.53207 v2.0.50727) I was using from 2009. This one does scan. I have attached image The top label is from C1.Report.4 and the bottom one is from C1.Report.2. You can see that there is a more pronounced spacing between the bars.

  • Replied 10 September 2017, 11:51 am EST

    Could you please make an actual C# sample that I could run locally demonstrating the problem, zip it up and post it here (it need not be a web site - just a WinForms C# program generating the report and exporting it to a PDF file)? A complete sample would be much better than me copying/pasting your code above and trying to recreate the issue as there might be some nuances affecting the result. If you post a sample I will look into it ASAP (or you could email it directly to me: dima at componentone.com - if you email it please post a note here so that I don't miss the email). Thanks.
  • Replied 10 September 2017, 11:51 am EST

    the problem exists in how to generate barcode and read barcode from pdf report. here is some sample codes and trial dlls that you can use to create a project, generate barcode and finish [url=http://www.keepdynamic.com/barcoding/asp-net-barcode-generator.shtml]print of bar codes[/url]. good luck. on the pdf report with barcode.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels