Menu

#17 BarcodeImageHandler | disable label underline

open
Swing/AWT (4)
5
2024-03-28
2007-01-16
No

Hi,

I am saving Barcode in either PNG or JPEG format but the label of the barcode is having underline. I am rendering those barcode into a table for preview, no underline appears but inside the image file it does.

Does anybody know how disable the label's underline in the output file. I have already tried setup Font into the Barcode.

FYI: And for some reason the GIF format doesn't work (this is not important).

The following is code snippet which is part of my codebase:

[code]
.....
// The BarcodeBean is my bean that encapsulate all the
// barcode related parameters
BarcodeBean barcodeBean= <get instanceof the bean>
// Create the barcode with the text
Barcode barcode = BarcodeFactory.createCode128(barcodeBean.getBarcodeText());
// This doesn't make much difference
barcode.setDrawingQuietSection(false);
// Setup the barcode width (defaulted to 1 pix)
barcode.setBarWidth(barcodeBean.getBarcodeWidth());
// Setup the barcode height (defaulted to 25 pix)
barcode.setBarHeight(barcodeBean.getBarcodeHeight());
// Set the title which not same as the barcode text
barcode.setLabel(barcodeBean.getTitle());
// Save as JPEG
BarcodeImageHandler.saveJPEG(barcode, new File(barcodeBean.getBarcodeImageFile());
.....
[/code]

Thanks
Digerati.

Discussion

  • Digerati Duke

    Digerati Duke - 2007-01-16

    JPEG FILe

     
  • Sean Sullivan

    Sean Sullivan - 2007-03-25

    Logged In: YES
    user_id=156581
    Originator: NO

    Did you find this bug in Barbecue 1.1? Can you reproduce the bug in Barbecue 1.5 alpha 3?

     
  • Sean Sullivan

    Sean Sullivan - 2007-03-25
    • assigned_to: ibourke --> sullis
     
  • Tom Nagle

    Tom Nagle - 2007-04-28

    Logged In: YES
    user_id=990421
    Originator: NO

    I found this issue in 1.5 alpha 3 and believe it can be fixed by editing the constructor in CenteredLabelLayout.java and changing the line:

    super(x, y, width, NOT_SET);

    To

    super(x, y, width, BARS_TEXT_VGAP);

    I have not done a full impact analysis of this change, I just know that it fixes the problem for my particular needs.

    HTH.

     
  • raja b

    raja b - 2008-07-29

    Logged In: YES
    user_id=2162297
    Originator: NO

    yes, i am using Barbecue 1.5 alpha 3 in jsp page.

     
  • gopal

    gopal - 2009-10-08

    Is there any ETA on this fix, as it's blocking us to use this software?

     
  • Kevin

    Kevin - 2009-11-17

    I use Barbecue 1.5 Beta 1. The problem still exist.
    The constructor in file CenteredLabelLayout.java is already updated with super(x, y, width, BARS_TEXT_VGAP);

    Any solution?

     
  • D N

    D N - 2024-03-28

    One solution: Change SizingOutput.java drawText() to:

    public int drawText(String text, LabelLayout labelLayout) throws OutputException {
            if(font == null || fm == null) {
                return 0;
            }
            GlyphVector gv = fm.getFont().layoutGlyphVector(fm.getFontRenderContext(), text.toCharArray(), 0, text.length(), Font.LAYOUT_LEFT_TO_RIGHT);
            Rectangle2D r2d = gv.getVisualBounds();
            return (int)r2d.getHeight() + CenteredLabelLayout.BARS_TEXT_VGAP + 1;
        }
    
     

Log in to post a comment.

MongoDB Logo MongoDB