none
Barcode (font) in SSRS 2008 R2 Reports

    Question

  • Hi,

     

    We're using ReportBuilder 3.0 to build SSRS 2008 R2.

    Now, in my report I want to add a barcode (type EAN-13).

     

    I found a font (.TTF) that translates the number in a barcode with that number below,

    I tried it out in Word and I'm getting exactly what I needed (the number generation will be handled in code in website application).

     

    After installing the font on both my computer (developer's pc) and the server running SSRS,

    I also tried it in Report Builder 3.0.

    When in Design Mode you can see the barcode as it should be.

    When running the report, you can also see the barcode:


    But now comes the problem:

    When running the report from Report Builder 3.0 and after clicking 'Print Layout'

    or after printing the document from the code, the barcode isn't shown,

    instead I see the numbers of the barcode in a default font (I think Arial) like this:

     

     

    Does anyone encountered a simular issue?

    And/Or does anyone has a solution to print the barcodes when value is for example 0012345678905 (EAN-13),

    using only ReportBuilder 3.0 and SSRS 2008 R2?

     

    Thursday, August 18, 2011 9:29 AM

Answers

  • Dear all,

     

    Search no longer!

    Well I hope this bug is fixed by next release, but I have found a workaround!

     

    Add the System.Drawing dll to the report-references and add some code to convert text to an bytes-array that represents the image of the text in the wished font.

    Then add a ImageBox to your report and set it's property to DataBase and then in expressions do something like '=Code.GenerateImage(<fontname>, <text)'

    Your text will be rendered as image and so always shown correctly (report, PDF, TIFF...)

    See following link:

    http://www.ssrstips.com/free-reporting-services-barcodes

     

    This person is a genious!

    I'm creating a dll that should allow to convert text to any kind of style, color, font, size...

     

    Kind regards,

     

    Lawrence

     

     

    Wednesday, August 24, 2011 1:21 PM

All replies

  • If you deploy the report to the report server and render it in the browser (to HTML), do you see the barcode? If not, the barcode font may not be correctly installed on the server.


    Program Manager, SQL Server Reporting Services
    Tuesday, August 23, 2011 3:20 AM
  • Hi Lawrence,

    Thanks for your question and Riccardo0’s suggestion.

    When you click on Print Layout in BIDS or Report Builder, the report rendered in PDF format. For your problem, I guess that your PDF environment doesn’t contain the barcode (type EAN-13).

    To resolve it, please ensure the barcode font has been installed on the server, and your Reporting Services 2008 is within Cumulative Update #1 installed.

    For more detail information, please refer to: Exporting SSRS 2008 Report to TIFF or PDF looses barcode.

    Thanks,
    Sharp


    Please remember to mark the replies as answers if they help you and unmark them if they provide no help.
    Wednesday, August 24, 2011 3:15 AM
    Moderator
  • Hi,

     

    First of all, thank you for your quick replies!
    It has becoming an urgent issue, we're even considering using another reporting system.

     

    I installed the font succesfully on the SSRS server.
    Restarted the SSRS service and then the font was displayed but not correctly!

     

    There's extra spacing between each character (for a barcode, this is unusable).
    Like this:

     

     

    When rendered through the Report Manging Website, it displays correctly (also in Report Builder 3.0 design WITHOUT Print Layout!):

     

     

    Exporting to TIFF or PDF will not display the text in the barcode-font.
    Exporting to Excel will show everything corectly, since excel can display the font correctly.

     

    I need to render the report from the reportserver and print it in code behind (no user controls, user only see report on paper).
    This gives same result. In fact I do not realy care about displaying it in PDF, although it would be nice.

    I render the report in 'emf' in code behind like this:

     private byte[][] RenderReport(string reportPath, CLGroup.Intranet.ReportingServerExecution.ParameterValue[] reportParameters)
        {
          // Private variables for rendering
          string deviceInfo = null;
          string format = "IMAGE";
          Byte[] firstPage = null;
          string encoding;
          string mimeType;
          CLGroup.Intranet.ReportingServerExecution.Warning[] warnings = null;
          CLGroup.Intranet.ReportingServerExecution.ParameterValue[] reportHistoryParameters = null;
          string[] streamIDs = null;
          Byte[][] pages = null;
          string extension = null;
          string historyID = null;
          List<Byte[]> secPages = new List<byte[]>();
    
          // Build device info based on the start page
          deviceInfo = String.Format(@"<DeviceInfo><OutputFormat>{0}</OutputFormat></DeviceInfo>", "emf");
          ExecutionInfo execInfo = new ExecutionInfo();
    
          ExecutionHeader execHeader = new ExecutionHeader();
          rs.ExecutionHeaderValue = execHeader;
    
          execInfo = rs.LoadReport(reportPath, historyID);
    
          rs.SetExecutionParameters(reportParameters, "nl-be");
    
          //Execute the report and get page count.
          try
          {
            // Renders the first page of the report and check if there are other pages
            
            m_numberOfPages = 0;
    
            Byte[] CurrentPage;
            CurrentPage = rs.Render(format, deviceInfo, out extension, out mimeType, out encoding, out warnings, out streamIDs);
            m_numberOfPages = 0;
    
            while (CurrentPage.Length > 0)
            {
              secPages.Add(CurrentPage);
              m_numberOfPages++;
              deviceInfo =
                String.Format(@"<DeviceInfo><OutputFormat>{0}</OutputFormat><StartPage>{1}</StartPage></DeviceInfo>",
                "emf", m_numberOfPages + 1);
              CurrentPage = rs.Render(format, deviceInfo, out extension, out mimeType, out encoding, out warnings, out streamIDs);          
            }
          }
    


    And prints like this:

     public bool Print(string report, CLGroup.Intranet.ReportingServerExecution.ParameterValue[] reportParameters, bool landscape)
        {
          this.RenderedReport = this.RenderReport(report, reportParameters);
          try
          {
            // Wait for the report to completely render.
            if (m_numberOfPages < 1)
              return false;
            PrinterSettings printerSettings = new PrinterSettings();
            printerSettings.MaximumPage = m_numberOfPages;
            printerSettings.MinimumPage = 1;
            printerSettings.PrintRange = PrintRange.SomePages;
            printerSettings.FromPage = 1;
            printerSettings.ToPage = m_numberOfPages;
            printerSettings.PrinterName = _printer;
            
    
            PrintDocument pd = new PrintDocument();
            m_currentPrintingPage = 1;
            m_lastPrintingPage = m_numberOfPages;
            pd.PrinterSettings = printerSettings;
            pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
            pd.DefaultPageSettings.Landscape = landscape;
             
    
            // Print report
            Console.WriteLine("Printing report...");
            pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
            pd.Print();
          }
    


     

    I'm guessing the SSRS server has problems generating Imported TTF-fonts.
    This same issue appears for every font I install and use in the report.
    My font is embedded enable though:

     

     

    BTW, My SSRS version is 10.50.1600.1
    I cannot use BID since we only have VS 2010 and not VS 2008, so I'm using report Builder 3.0

    I'm sure I'm not the only one experiencing this issue with external True Type Fonts,
    any help or work around on this bug would greatly be appreciated!

    Kind regards,

    Lawrence

    Wednesday, August 24, 2011 9:50 AM
  • Dear all,

     

    Search no longer!

    Well I hope this bug is fixed by next release, but I have found a workaround!

     

    Add the System.Drawing dll to the report-references and add some code to convert text to an bytes-array that represents the image of the text in the wished font.

    Then add a ImageBox to your report and set it's property to DataBase and then in expressions do something like '=Code.GenerateImage(<fontname>, <text)'

    Your text will be rendered as image and so always shown correctly (report, PDF, TIFF...)

    See following link:

    http://www.ssrstips.com/free-reporting-services-barcodes

     

    This person is a genious!

    I'm creating a dll that should allow to convert text to any kind of style, color, font, size...

     

    Kind regards,

     

    Lawrence

     

     

    Wednesday, August 24, 2011 1:21 PM
  • Thanks for these additional details. Could you create a Connect bug at https://connect.microsoft.com/SQLServer/Feedback? Please attach a simple report that we can render, the barcode font, and some screenshots or exported reports (PDF, TIFF), and we can investigate.


    Program Manager, SQL Server Reporting Services
    Wednesday, August 24, 2011 5:16 PM
  • Hi Ricardo,

    I see that the reporting services team may have worked on this issue. Any updates?

    Regards,

    Jan

    Thursday, March 01, 2012 10:47 PM
  • please check the .NET barcode control for SSRS. download the barcode encoder dll first, then integrate it into your reports and the barcode generation function will be added. Finally you can generate many barcodes in your reports.
    Monday, March 19, 2012 2:55 PM
  • I met a similar problem, and I plan to buy a barcode generator for reporting service. But I do know whether it is worth buying? By the way, do you know BarcodeLib? is this website reliable?
    Monday, December 24, 2012 9:32 AM
  • Easier to use barcode dll for reporting services to generate barcode in images,

    http://www.avapose.com/dotnet_barcode_reporting_service/

    Friday, March 29, 2013 8:28 AM