Barcodes

Hello,

Is it possible to generate a barcode into a c# bitmap object using fast report.net or can bitmaps only be created in a report?

Thanks,

- Anthony

Comments

  • edited 7:37PM
    Hello,

    You may export your report that contain barcodes, into the image file (bmp, png, ...). Is this what you want?
  • edited 7:37PM
    AlexTZ wrote: »
    Hello,

    You may export your report that contain barcodes, into the image file (bmp, png, ...). Is this what you want?

    Well, it would be prefered to be a memory bitmap, the situation is there's a report with barcodes on, and this report has a matching document in another piece of software, my software can open these files and past images into it and I'd like to be able to paste a barcode on the document (using code) so it can be matched to the report.

    Here's a snip of the type of code I'd like to be able to use


    BarcodeGenerator Barcode = new Barcode("123456789");
    Barcode.Symbiology = "Code39";
    Bitmap barcodeImage = (Bitmap)Barcode.GetImage();

    //Copy the barcode image into Clipboard
    Clipboard.SetDataObject(barcodeImage);

    Then I can paste it from the clipboard into the app.

    I'd really like to avoid using temp files, if the above is not possible, hwo about the ability to have a Report.GetOutputAsBitmaps() which returns a report as an array of Bitmaps, then I can make a small report into memory bitmap?

    Many thanks,

    - anthony
  • edited 7:37PM
    You can use the following code:
          BarcodeObject barcode = new BarcodeObject();
          barcode.SymbologyName = "Code39";
          barcode.Text = "123456789";
          barcode.Height = 64;
    
          // to get actual width, we must draw the barcode first
          using (Bitmap tempBmp = new Bitmap(1, 1))
          using (Graphics g = Graphics.FromImage(tempBmp))
          using (GraphicCache cache = new GraphicCache())
          {
            barcode.Draw(new FRPaintEventArgs(g, 1, 1, cache));
          }
    
          // now we know width and height, perform the drawing
          Bitmap bmp = new Bitmap((int)barcode.Width, (int)barcode.Height);
          using (Graphics g = Graphics.FromImage(bmp))
          using (GraphicCache cache = new GraphicCache())
          {
            g.Clear(Color.White);
            barcode.Draw(new FRPaintEventArgs(g, 1, 1, cache));
          }
    
          bmp.Save(...);
    
  • edited November 2009
    Fantastic, I'll try that!

    Next question,
    I don't think fast reports supports Databar barcodes, one of which (Databar Expanded), in a small amount of space can fit 41 alphanumeric characters! (or 74 digits!)

    http://mdn.morovia.com/manuals/databar-fontware/ch02s02.php

    They provide free sample software (with c source code) here:

    http://www.gs1.org/barcodes/databar/software
    (http://www.gs1.org/sites/default/files/docs/barcodes/databar/GS1_DataBar_Software.zip)

    Would it be possible to build support in for fast reports?

    If not, is code128 the most compact barcode?

    Many thanks,

    - Anthony
  • edited 7:37PM
    Sorry, it requires too much efforts to implement it. We don't have such plans in the near future.
  • edited 7:37PM
    Ok,

    no problem, but could you tell me which barcode that fast report supports fits most data into a small space? I think code128 is compact, but are any other's better?

    - Anthony
  • edited 7:37PM
    Hello,

    You may look at 2D barcodes such as PDF417 and DataMatrix.
  • edited 7:37PM
    I myself came across the same problem and found that DataMatrix barcodes were definatly the best to use as barcode labels. Dont get me wrong thePDF417 are ok but my personal preference is the DataMatrix
  • edited 7:37PM
    Does anyone have a snippet for pdf417 Barcode. I'm new to FastReports, it would be greatly appreciated.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.