From: Jeremias M. <de...@je...> - 2009-03-14 15:44:23
|
On 14.03.2009 08:28:02 Kenny De Metter wrote: > > I have a few questions regarding barcode4j : > > Am i correct that you can set the width ( width of the narrowest module ) of a barcode , by following formula ? : > > module width = 25.4 * ( width of narrowest bar ( in dots ) / resolution (in dpi ) ) Yes, that formula would output the module width in mm as required by the bean API. You can simplify that in Java code like that: setModuleWidth(UnitConv.in2mm( widthInDots / resolution )); > Am i correct that this module width should be between the defined > minimum and maximum module width , for a certain barcode kind ( for > instance EAN128 , minimum 0.21 , max 1.016 ) . Right. > Am i correct that doing so , should ensure that the barcode is always readable ? Normally yes, but it always also depends on the printer's quality, contrast etc. At any rate, this is the most promising approach. > Then , what is the exact influence the resolution has ( which resolution should i use , in which cases ) ? If you generate a bitmap with a resolution of 72dpi, then it makes sense to make sure the narrow module width is a multiple of one pixel. Otherwise, the quality suffers from sub-pixel artifacts (anti-aliasing or missing pixels). If you're printing to a 300 dpi printer, the same applies. At 600 dpi this is mostly no problem anymore since a narrow bar would almost always already be multiple pixels wide which increases the chance of a good read. Take a look at a PDF I've posted recently. It illustrated this topic: http://sourceforge.net/mailarchive/attachment.php?list_name=barcode4j-users&message_id=20090220114425.0C97.60BA733C%40jeremias-maerki.ch&counter=1 > When i generate the images , and put them in Word , it works fine , i get image that are readable by my barcode reader. > > However , when i just should the images in a browser , they are a lot bigger. > Am i correct that this is because it transforms the resolution to the screen resolution, thus increasing it's size ? I assume so, yes. I think for the browser it makes sense to use the smallest resolution possible that still stays in the acceptable module width region. > The problem is , that the pdf conversion software i'm using ( converts > html to pdf ) , also seems to convert to the screen resolution, leading > to enormous images. > For this , i need to know what the normal expected behaviour should be. Well, I guess that really depends on how the HTML interpreter behaves. I guess the most important information would be the resolution at which the HTML interpreter works. If it works at 96 dpi, then it's best to produce a barcode bitmap at 96dpi. I think the big problem is that HTML is too focused on pixels (i.e. the screen) than to work fine when printed. Imagine only the Ctrl-+/- combination to change the zoom factor in Firefox. Do you even know what the expected size of any bitmap is on the printed page afterwords. You can already guess from that: I don't really know how best to solve this. I would probably try to find out if you can work with absolute lengths (inches, millimeters) rather than pixels in HTML or if you can switch to something like XSL-FO where you don't have such problems, especially since you can generate the barcode as vector graphics. But I assume you don't have that option. You probably just have to make sure a particular HTML page also comes out correctly when printed. My suggestion: Try to stay at 72 or 96 dpi for the barcode bitmaps. Make sure that resolution gets written into the bitmap file's (PNG?) metadata. Try to get a module width of 1 or 2 pixels (as low as possible). > Sorry for the all the questions , I have no problem with that. I think it's better to ask so many questions than just to say "it doesn't work" and the person on the other side has no data to work with. > Kenny, > HTH Jeremias Maerki |