Re: Barcode won't scan if Rendered Image is too small
"Andrew Nelson" <[email protected]> Wed, 05 Nov 2003 18:18:39 -0700
| Newsgroups | gmane.comp.krysalis.user |
|---|---|
| Message-ID | <[email protected]> |
Well I managed to get the size to modify but I can't seem to get the font to do anything. Not sure what would be best but I have attached the files I modified. Looking through your code I can tell allready that you are a far better developer than I so you may want to look through my code very carefully to be sure I haven't done anything dumb. Anyhow if these changes should get commited it will be my first contribution to the opensource world so thank you much for the opportunity. I don't have any idea why the font doesn't work but I haven't had a ton of time to work on this so maybe tommorow when I have more time I can try and see what exactly is going on. Andy >>> [email protected] 11/05/03 03:43PM >>> I'd love to try and help if I can. I'm what I'd like to call an ok developer. So we'll see what I can come up with. >>> [email protected] 11/05/03 03:07PM >>> Ok, I checked that. It works as I would expect it to. The human readable part scales with the bitmap resolution. Of course, if you only modify the module width you don't get smaller characters, only narrower bars. I guess that was the problem. Neither the servlet nor the barcode XML can control the font and font size, yet. I guess that's one of the points where real-life usage of package brings additional requirements. Would you like to implement that yourself? It should be rather easy. It's only a matter of changing GenericBarcodeImpl and the servlet code. I'd be glad to apply any patches. By the way, I also tried the formula I've given earlier. It seems to work, although due to lack of a barcode scanner I can't test the readability. Ironic, isn't it, being the main author of the package? At least, I've been getting pretty good at reading barcodes by hand. :-) On 05.11.2003 08:40:50 Jeremias Maerki wrote: > > 2. The > > human readable output doesn't seem to scale down in size with the > > smaller image. > > It should. I can check that this evening (in about 10 hours here). Jeremias Maerki ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ krysalis-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/krysalis-users ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ krysalis-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/krysalis-users
index.jsp
(text/html, 7.4 KB)
<%@ page contentType="text/html" %>
<jsp:useBean id="bcrequest" class="org.krysalis.barcode.webapp.BarcodeRequestBean" scope="request"/>
<jsp:setProperty name="bcrequest" property="*"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Krysalis Barcode Servlet</title>
</head>
<body>
<h1>Krysalis Barcode Servlet</h1>
<p>This page demostrates the usage of the BarcodeServlet.</p>
<%
final String genbc = bcrequest.toURL();
if (bcrequest.isSVG()) {
%>
<p>The generated barcode in SVG format (only displayed if SVG is supported in your browser):</p>
<p>
<!--object type="image/svg+xml" data="http://localhost:8080/krysalis-barcode/gensvg?type=code128&msg=123&ext=.svg" name="DynamicBarcode" width="400" height="150"/-->
<embed src="<%=genbc%>" pluginspage="http://www.adobe.com/svg/viewer/install/" width="100%" height="100"/>
</p>
<%
} else if (bcrequest.isBitmap()) {
%>
<p>The generated barcode in <%=bcrequest.getFormat()%> format (only displayed if <%=bcrequest.getFormat()%> is supported on the server and in your browser):</p>
<p>
<img src="<%=genbc%>"/>
</p>
<%
} else {
%>
<p><i>The generated barcode cannot be previewed. Format is <%=bcrequest.getFormat()%>.</i></p>
<%
}
%>
<p>The following is the URL that was used to create the above barcode:</p>
<table width="100%" border="1" rules="none" cellpadding="5">
<tr>
<td width="100%">
<p>
<a href="<%=genbc%>"><%=genbc%></a>
</p>
</td>
</tr>
</table>
<p>Change the parameters:</p>
<form method="post" action="index.jsp">
<table border="0">
<tr>
<td>
<p>Output format (required):</p>
</td>
<td>
<p>
<select name="format">
<%
final String[] FORMATS = new String[] {"svg", "eps", "jpeg", "tiff", "png", "gif"};
for (int i = 0; i < FORMATS.length; i++) {
out.print("<option");
if (FORMATS[i].equals(bcrequest.getFormat())) {
out.print(" selected=\"selected\"");
}
out.print(">");
out.print(FORMATS[i]);
out.println("</option>");
}
%>
</select>
</p>
</td>
<td>
<p>Some bitmap formats won't work if there's no image encoder available for this format.</p>
</td>
</tr>
<tr>
<td>
<p>Grayscale:</p>
</td>
<td>
<p>
<input type="checkbox" name="gray" <%= (bcrequest.isGray() ? " checked=\"checked\"" : "") %>/>
</p>
</td>
<td>Applies to bitmap formats only (JPEG, PNG etc.)</td>
</tr>
<tr>
<td>
<p>Bitmap resolution (in dpi):</p>
</td>
<td>
<p>
<input type="text" name="resolution" value="<%= (bcrequest.getResolution() != null ? bcrequest.getResolution() : "") %>"/>
</p>
</td>
<td>
<p>Applies to bitmap formats only. Example: 300</p>
</td>
</tr>
<tr>
<td>
<p>Barcode type (required):</p>
</td>
<td>
<p>
<select name="type">
<%
final String[] BARCODES = new String[] {"code128", "code39", "codabar", "ean-13", "ean-8", "intl2of5", "upc-a", "upc-e", "postnet"};
for (int i = 0; i < BARCODES.length; i++) {
out.print("<option");
if (BARCODES[i].equals(bcrequest.getType())) {
out.print(" selected=\"selected\"");
}
out.print(">");
out.print(BARCODES[i]);
out.println("</option>");
}
%>
</select>
</p>
</td>
</tr>
<tr>
<td>
<p>Message (required):</p>
</td>
<td>
<p>
<input type="text" name="msg" value="<%= (bcrequest.getMsg() != null ? bcrequest.getMsg() : "") %>"/>
</p>
</td>
</tr>
<tr>
<td>
<p>Height:</p>
</td>
<td>
<p>
<input type="text" name="height" value="<%= (bcrequest.getHeight() != null ? bcrequest.getHeight() : "") %>"/>
</p>
</td>
<td>
<p>Example: 2.5cm</p>
</td>
</tr>
<tr>
<td>
<p>Module Width:</p>
</td>
<td>
<p>
<input type="text" name="moduleWidth" value="<%= (bcrequest.getModuleWidth() != null ? bcrequest.getModuleWidth() : "") %>"/>
</p>
</td>
<td>
<p>Example: 0.3mm</p>
</td>
</tr>
<tr>
<td>
<p>Wide Factor:</p>
</td>
<td>
<p>
<input type="text" name="wideFactor" value="<%= (bcrequest.getWideFactor() != null ? bcrequest.getWideFactor() : "") %>"/>
</p>
</td>
<td>
<p>Example: 2 or 3</p>
</td>
</tr>
<tr>
<td>
<p>Enable Quiet Zone:</p>
</td>
<td>
<p>
<input type="text" name="quietZone" value="<%= (bcrequest.getQuietZone() != null ? bcrequest.getQuietZone() : "") %>"/>
</p>
</td>
<td>
<p>Example: 10mw or 1cm. Use "disable" to disable the quiet zone.</p>
</td>
</tr>
<tr>
<td>
<p>Placement of human-readable part:</p>
</td>
<td>
<p>
<select name="humanReadable">
<%
final String[] HRPOSITIONS = new String[] {"[default]", "top", "bottom", "none"};
String hrpos = bcrequest.getHumanReadable();
if (hrpos == null) {
hrpos = HRPOSITIONS[0];
}
for (int i = 0; i < HRPOSITIONS.length; i++) {
out.print("<option");
if (HRPOSITIONS[i].equals(hrpos)) {
out.print(" selected=\"selected\"");
}
out.print(">");
out.print(HRPOSITIONS[i]);
out.println("</option>");
}
%>
</select>
</p>
</td>
</tr>
<tr>
<td>
<p>Human Readable Size</p>
</td>
<td>
<p>
<input type="text" name="humanReadableSize" value="<%= (bcrequest.getHumanReadableSize() != null ? bcrequest.getHumanReadableSize() : "") %>"/>
</p>
</td>
<td>
<p>Example: 8.0</p>
</td>
</tr>
<tr>
<td/>
<td>
<p>
<input type="submit" value="Generate!"/>
</p>
</td>
</tr>
</table>
</form>
<p>
For the documention on <b>Krysalis Barcode</b>, please visit <a href="http://www.krysalis.org/barcode" target="_blank">http://www.krysalis.org/barcode</a>.
</p>
</body>
</html>
BarcodeServlet.java
(application/octet-stream, 11.7 KB) - not displayed
GenericBarcodeImpl.java
(application/octet-stream, 10.1 KB) - not displayed
BarcodeRequestBean.java
(application/octet-stream, 8.5 KB) - not displayed