On 26.08.2009 09:52:21 Ben Smith wrote:
> If I want to create a label (4" x 3") with barcode128 on the bottom
> right and some text metadata (4 lines) above the barcode, can you
> please give some advice about how to do this?
I'd probably do it using Apache FOP (i.e. XSL-FO) which supports
generating bitmap output (assuming that's what you want). That would let
you large ignore the resolution aspect as FOP will handle that for you.
Depending on what you do with the label you could even use a vector
graphics format instead (PDF, PostScript etc.)
> It is hard to figure out what resolution for such a label. If I set
> resolution 300, then draw the text, the text is very small compared to
> the barcode.
How do you currently generate the label? It's a bit difficult to guess
what's going wrong without more context information. In case you do this
on the Java2D level, be aware that the font sizes are specified in
pixels, not in absolute size. So when you increase the resolution, you
have to increase the font size, too. You can use Barcode4J's UnitConv
class to do conversions from absolute sizes to pixels given a resolution.
int resolution = 300;
int pixelSize = UnitConv.mm2px(UnitConv.pt2mm(12.0), resolution);
Font f = new Font("Arial", Font.PLAIN, pixelSize);
(or something like that)
> Does Bardoce4J have implementation of Barcode Font?
No, that's the clue about Barcode4J: it doesn't use barcode fonts. It's
either using barcode fonts or using Barcode4J. Two separate approaches, both
with pros and cons. You'd have to look elsewhere for barcode fonts.
> What would be your suggestions about the module width, resolution, and
> how I could draw the metadata text string on the label so that it
> matches the barcode and its message text size underneath?
My usual suggestion to people who want to have more complex text around
the barcode is to disable the human-readable part completely and do all
text using a different means (Java2D, XSL-FO, SVG etc.).