1003862 Barcode type UPC A is needed for print formats going to Amazon. Added UPCA support using barcode4j. Use barcode4j instead of barbecue as I can't get decent output from barbecue, barbecue have the underline bug and barbecue is a dead project. Should completely drop the use of barbecue in future.
This commit is contained in:
parent
669b5e65f0
commit
bc2d581399
|
@ -0,0 +1,7 @@
|
|||
-- Apr 2, 2014 3:38:01 PM COT
|
||||
-- 1003862-Barcode type UPC A is needed for print formats going to Amazon
|
||||
INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Reference_ID,AD_Ref_List_ID,AD_Ref_List_UU,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,377,200176,'79d36566-b888-4fc1-931d-c0b1612c709b',TO_DATE('2014-04-02 15:53:38','YYYY-MM-DD HH24:MI:SS'),100,'D','Y','UPC-A',TO_DATE('2014-04-02 15:53:38','YYYY-MM-DD HH24:MI:SS'),100,'UPA')
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201404020400_Ticket_1003862.sql') FROM dual
|
||||
;
|
|
@ -0,0 +1,7 @@
|
|||
-- Apr 2, 2014 3:38:01 PM COT
|
||||
-- 1003862-Barcode type UPC A is needed for print formats going to Amazon
|
||||
INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Reference_ID,AD_Ref_List_ID,AD_Ref_List_UU,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,377,200176,'79d36566-b888-4fc1-931d-c0b1612c709b',TO_TIMESTAMP('2014-04-02 15:53:38','YYYY-MM-DD HH24:MI:SS'),100,'D','Y','UPC-A',TO_TIMESTAMP('2014-04-02 15:53:38','YYYY-MM-DD HH24:MI:SS'),100,'UPA')
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201404020400_Ticket_1003862.sql') FROM dual
|
||||
;
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="barcode4j-2.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="vt-dictionary-3.0.jar">
|
||||
<attributes>
|
||||
<attribute name="javadoc_location" value="http://vt-middleware.googlecode.com/svn/vt-dictionary/javadoc/vt-dictionary-3.0"/>
|
||||
|
|
|
@ -19,6 +19,7 @@ Bundle-ClassPath: base.jar,
|
|||
vt-dictionary-3.0.jar,
|
||||
vt-password-3.1.1.jar,
|
||||
super-csv-2.0.0-beta-1.jar,
|
||||
barcode4j-2.1.jar,
|
||||
bctsp-jdk14-1.38.jar,
|
||||
bcmail-jdk14-1.38.jar,
|
||||
bcprov-jdk14-1.38.jar
|
||||
|
@ -325,6 +326,27 @@ Export-Package: bsh,
|
|||
org.jfree.ui.action,
|
||||
org.jfree.ui.tabbedui,
|
||||
org.jfree.util,
|
||||
org.krysalis.barcode4j,
|
||||
org.krysalis.barcode4j.ant,
|
||||
org.krysalis.barcode4j.cli,
|
||||
org.krysalis.barcode4j.impl,
|
||||
org.krysalis.barcode4j.impl.codabar,
|
||||
org.krysalis.barcode4j.impl.code128,
|
||||
org.krysalis.barcode4j.impl.code39,
|
||||
org.krysalis.barcode4j.impl.datamatrix,
|
||||
org.krysalis.barcode4j.impl.fourstate,
|
||||
org.krysalis.barcode4j.impl.int2of5,
|
||||
org.krysalis.barcode4j.impl.pdf417,
|
||||
org.krysalis.barcode4j.impl.postnet,
|
||||
org.krysalis.barcode4j.impl.upcean,
|
||||
org.krysalis.barcode4j.output,
|
||||
org.krysalis.barcode4j.output.bitmap,
|
||||
org.krysalis.barcode4j.output.eps,
|
||||
org.krysalis.barcode4j.output.java2d,
|
||||
org.krysalis.barcode4j.output.svg,
|
||||
org.krysalis.barcode4j.servlet,
|
||||
org.krysalis.barcode4j.tools,
|
||||
org.krysalis.barcode4j.xalan,
|
||||
org.supercsv.cellprocessor,
|
||||
org.supercsv.cellprocessor.constraint,
|
||||
org.supercsv.cellprocessor.ift,
|
||||
|
|
|
@ -34,6 +34,7 @@ bin.includes = META-INF/,\
|
|||
OSGI-INF/defaulttaxproviderfactory.xml,\
|
||||
OSGI-INF/addressvalidationeventhandler.xml,\
|
||||
schema/,\
|
||||
barcode4j-2.1.jar,\
|
||||
bctsp-jdk14-1.38.jar,\
|
||||
bcmail-jdk14-1.38.jar,\
|
||||
bcprov-jdk14-1.38.jar
|
||||
|
|
|
@ -398,6 +398,8 @@ public class X_AD_PrintFormatItem extends PO implements I_AD_PrintFormatItem, I_
|
|||
public static final String BARCODETYPE_Code39LinearWOChecksum = "c39";
|
||||
/** EAN 13 = E13 */
|
||||
public static final String BARCODETYPE_EAN13 = "E13";
|
||||
/** UPCA = UPCA*/
|
||||
public static final String BARCODETYPE_UPCA = "UPA";
|
||||
/** Set Barcode Type.
|
||||
@param BarcodeType
|
||||
Type of barcode
|
||||
|
|
|
@ -24,11 +24,16 @@ import java.util.Properties;
|
|||
|
||||
import net.sourceforge.barbecue.Barcode;
|
||||
import net.sourceforge.barbecue.BarcodeFactory;
|
||||
import net.sourceforge.barbecue.BarcodeImageHandler;
|
||||
import net.sourceforge.barbecue.linear.ean.UCCEAN128Barcode;
|
||||
import net.sourceforge.barbecue.output.OutputException;
|
||||
|
||||
import org.compiere.print.MPrintFont;
|
||||
import org.compiere.print.MPrintFormatItem;
|
||||
import org.krysalis.barcode4j.BarcodeDimension;
|
||||
import org.krysalis.barcode4j.ChecksumMode;
|
||||
import org.krysalis.barcode4j.HumanReadablePlacement;
|
||||
import org.krysalis.barcode4j.impl.upcean.UPCABean;
|
||||
import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider;
|
||||
|
||||
/**
|
||||
* Barcode Print Element
|
||||
|
@ -60,7 +65,7 @@ public class BarcodeElement extends PrintElement
|
|||
m_valid = false;
|
||||
|
||||
createBarcode(code, item);
|
||||
if (m_barcode == null)
|
||||
if (m_barcode == null && m_upc == null)
|
||||
m_valid = false;
|
||||
m_allowOverflow = item.isHeightOneLine(); // teo_sarca, [ 1673590 ]
|
||||
} // BarcodeElement
|
||||
|
@ -73,6 +78,9 @@ public class BarcodeElement extends PrintElement
|
|||
private boolean m_allowOverflow = true;
|
||||
private float m_scaleFactor = 1;
|
||||
|
||||
private UPCABean m_upc = null;
|
||||
private String m_code;
|
||||
|
||||
/**
|
||||
* Create Barcode
|
||||
* @param code barcode data string
|
||||
|
@ -131,7 +139,12 @@ public class BarcodeElement extends PrintElement
|
|||
m_barcode = BarcodeFactory.createUCC128(UCCEAN128Barcode.EAN128_AI, code);
|
||||
else if (type.equals(MPrintFormatItem.BARCODETYPE_EAN13)) //@Trifon
|
||||
m_barcode = BarcodeFactory.createEAN13(code); //@Trifon
|
||||
|
||||
else if (type.equals(MPrintFormatItem.BARCODETYPE_UPCA )) {
|
||||
m_upc = new UPCABean();
|
||||
m_upc.setChecksumMode(ChecksumMode.CP_AUTO);
|
||||
m_upc.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM);
|
||||
m_code = code;
|
||||
}
|
||||
// http://www.usps.com/cpim/ftp/pubs/pub97/97apxs_006.html#_Toc481397331
|
||||
else if (type.equals(MPrintFormatItem.BARCODETYPE_USPostalServiceUCCEAN128))
|
||||
{
|
||||
|
@ -145,7 +158,7 @@ public class BarcodeElement extends PrintElement
|
|||
{
|
||||
log.warning(code + " - " + e.toString());
|
||||
m_valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_valid && m_barcode != null)
|
||||
{
|
||||
|
@ -158,15 +171,6 @@ public class BarcodeElement extends PrintElement
|
|||
}
|
||||
} // createBarcode
|
||||
|
||||
/**
|
||||
* Get Barcode
|
||||
* @return Barcode
|
||||
*/
|
||||
public Barcode getBarcode()
|
||||
{
|
||||
return m_barcode;
|
||||
} // getBarcode
|
||||
|
||||
/**
|
||||
* Is Barcode Valid
|
||||
* @return true if valid
|
||||
|
@ -185,11 +189,31 @@ public class BarcodeElement extends PrintElement
|
|||
{
|
||||
p_width = 0;
|
||||
p_height = 0;
|
||||
if (m_barcode == null)
|
||||
if (m_barcode == null && m_upc == null)
|
||||
return true;
|
||||
|
||||
p_width = m_barcode.getWidth();
|
||||
p_height = m_barcode.getHeight();
|
||||
if (m_barcode != null)
|
||||
{
|
||||
p_width = m_barcode.getWidth();
|
||||
p_height = m_barcode.getHeight();
|
||||
|
||||
//convert from pixel to point/inch
|
||||
if (p_width > 0)
|
||||
p_width = p_width * 3f / 4f;
|
||||
if (p_height > 0)
|
||||
p_height = p_height * 3f / 4f;
|
||||
}
|
||||
else
|
||||
{
|
||||
BarcodeDimension t = m_upc.calcDimensions(m_code);
|
||||
//convert from mm to point/inch
|
||||
p_width = (float) (t.getWidthPlusQuiet() / 25.4f * 72f);
|
||||
p_height = (float) (t.getHeight() / 25.4f * 72f);
|
||||
|
||||
// * 3 for resolution of 216 dpi ( 72 * 3 )
|
||||
p_width *= 3f;
|
||||
p_height *=3f;
|
||||
}
|
||||
|
||||
if (p_width * p_height == 0)
|
||||
return true; // don't bother scaling and prevent div by 0
|
||||
|
@ -231,7 +255,7 @@ public class BarcodeElement extends PrintElement
|
|||
public void paint (Graphics2D g2D, int pageNo, Point2D pageStart,
|
||||
Properties ctx, boolean isView)
|
||||
{
|
||||
if (!m_valid || m_barcode == null)
|
||||
if (!m_valid || (m_barcode == null && m_upc == null ))
|
||||
return;
|
||||
|
||||
// Position
|
||||
|
@ -243,15 +267,28 @@ public class BarcodeElement extends PrintElement
|
|||
x += (p_maxWidth - p_width) / 2;
|
||||
int y = (int)location.y;
|
||||
|
||||
paint(g2D, x, y);
|
||||
} // paint
|
||||
|
||||
public void paint(Graphics2D g2D, int x, int y) {
|
||||
try {
|
||||
|
||||
int w = m_barcode.getWidth();
|
||||
int h = m_barcode.getHeight();
|
||||
BufferedImage image = null;
|
||||
|
||||
// draw barcode to buffer
|
||||
BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D temp = (Graphics2D) image.getGraphics();
|
||||
m_barcode.draw(temp, 0, 0);
|
||||
if (m_barcode != null)
|
||||
{
|
||||
// draw barcode to buffer
|
||||
image = BarcodeImageHandler.getImage(m_barcode);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//use resolution of 216 dpi (72 * 3) for better output
|
||||
BitmapCanvasProvider provider = new BitmapCanvasProvider(72*3, BufferedImage.TYPE_INT_ARGB, true, 0);
|
||||
m_upc.generateBarcode(provider, m_code);
|
||||
provider.finish();
|
||||
image = provider.getBufferedImage();
|
||||
}
|
||||
|
||||
// scale barcode and paint
|
||||
AffineTransform transform = new AffineTransform();
|
||||
|
@ -259,9 +296,10 @@ public class BarcodeElement extends PrintElement
|
|||
transform.scale(m_scaleFactor, m_scaleFactor);
|
||||
g2D.drawImage(image, transform, this);
|
||||
|
||||
} catch (OutputException e) {
|
||||
}
|
||||
} // paint
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* String Representation
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.awt.font.TextAttribute;
|
|||
import java.awt.font.TextLayout;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.Serializable;
|
||||
import java.text.AttributedCharacterIterator;
|
||||
import java.text.AttributedString;
|
||||
|
@ -41,9 +40,6 @@ import java.util.Properties;
|
|||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.barbecue.Barcode;
|
||||
import net.sourceforge.barbecue.output.OutputException;
|
||||
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.print.MPrintFormatItem;
|
||||
import org.compiere.print.MPrintTableFormat;
|
||||
|
@ -1477,34 +1473,8 @@ public class TableElement extends PrintElement
|
|||
}
|
||||
else if (printItems[index] instanceof BarcodeElement)
|
||||
{
|
||||
try {
|
||||
Barcode barcode = ((BarcodeElement)printItems[index]).getBarcode();
|
||||
if ( barcode != null )
|
||||
{
|
||||
double scale = ((BarcodeElement)printItems[index]).getScaleFactor();
|
||||
if ( scale != 1.0 )
|
||||
{
|
||||
int w = barcode.getWidth();
|
||||
int h = barcode.getHeight();
|
||||
|
||||
// draw barcode to buffer
|
||||
BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D temp = (Graphics2D) image.getGraphics();
|
||||
barcode.draw(temp, 0, 0);
|
||||
|
||||
// scale barcode and paint
|
||||
AffineTransform transform = new AffineTransform();
|
||||
transform.translate(curX,penY);
|
||||
transform.scale(scale, scale);
|
||||
g2D.drawImage(image, transform, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
barcode.draw(g2D, curX, (int)penY);
|
||||
}
|
||||
}
|
||||
} catch (OutputException e) {
|
||||
}
|
||||
BarcodeElement barcodeElement = (BarcodeElement)printItems[index];
|
||||
barcodeElement.paint(g2D, curX, (int)penY);
|
||||
}
|
||||
else if (printItems[index] instanceof Boolean)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="lib/xalan-2.7.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jackson-core-2.0.5.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/barcode4j-2.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jasperreports-fonts-5.1.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/commons-beanutils-1.8.0.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/commons-digester-2.1.jar"/>
|
||||
|
|
|
@ -8,7 +8,6 @@ Bundle-ClassPath: lib/commons-beanutils-1.8.0.jar,
|
|||
lib/jasperreports-5.1.2.jar,
|
||||
lib/jdt-compiler-3.1.1.jar,
|
||||
lib/jasperreports-fonts-5.1.2.jar,
|
||||
lib/barcode4j-2.1.jar,
|
||||
lib/jackson-core-2.0.5.jar,
|
||||
lib/xalan-2.7.1.jar
|
||||
Export-Package: .,
|
||||
|
@ -238,27 +237,6 @@ Export-Package: .,
|
|||
org.eclipse.jdt.internal.compiler.problem,
|
||||
org.eclipse.jdt.internal.compiler.util,
|
||||
org.eclipse.jdt.internal.core.util,
|
||||
org.krysalis.barcode4j,
|
||||
org.krysalis.barcode4j.ant,
|
||||
org.krysalis.barcode4j.cli,
|
||||
org.krysalis.barcode4j.impl,
|
||||
org.krysalis.barcode4j.impl.codabar,
|
||||
org.krysalis.barcode4j.impl.code128,
|
||||
org.krysalis.barcode4j.impl.code39,
|
||||
org.krysalis.barcode4j.impl.datamatrix,
|
||||
org.krysalis.barcode4j.impl.fourstate,
|
||||
org.krysalis.barcode4j.impl.int2of5,
|
||||
org.krysalis.barcode4j.impl.pdf417,
|
||||
org.krysalis.barcode4j.impl.postnet,
|
||||
org.krysalis.barcode4j.impl.upcean,
|
||||
org.krysalis.barcode4j.output,
|
||||
org.krysalis.barcode4j.output.bitmap,
|
||||
org.krysalis.barcode4j.output.eps,
|
||||
org.krysalis.barcode4j.output.java2d,
|
||||
org.krysalis.barcode4j.output.svg,
|
||||
org.krysalis.barcode4j.servlet,
|
||||
org.krysalis.barcode4j.tools,
|
||||
org.krysalis.barcode4j.xalan,
|
||||
org.w3c.tools.codec
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Import-Package: com.lowagie.text,
|
||||
|
@ -452,6 +430,27 @@ Import-Package: com.lowagie.text,
|
|||
org.codehaus.groovy.vmplugin,
|
||||
org.codehaus.groovy.vmplugin.v4,
|
||||
org.codehaus.groovy.vmplugin.v5,
|
||||
org.krysalis.barcode4j,
|
||||
org.krysalis.barcode4j.ant,
|
||||
org.krysalis.barcode4j.cli,
|
||||
org.krysalis.barcode4j.impl,
|
||||
org.krysalis.barcode4j.impl.codabar,
|
||||
org.krysalis.barcode4j.impl.code128,
|
||||
org.krysalis.barcode4j.impl.code39,
|
||||
org.krysalis.barcode4j.impl.datamatrix,
|
||||
org.krysalis.barcode4j.impl.fourstate,
|
||||
org.krysalis.barcode4j.impl.int2of5,
|
||||
org.krysalis.barcode4j.impl.pdf417,
|
||||
org.krysalis.barcode4j.impl.postnet,
|
||||
org.krysalis.barcode4j.impl.upcean,
|
||||
org.krysalis.barcode4j.output,
|
||||
org.krysalis.barcode4j.output.bitmap,
|
||||
org.krysalis.barcode4j.output.eps,
|
||||
org.krysalis.barcode4j.output.java2d,
|
||||
org.krysalis.barcode4j.output.svg,
|
||||
org.krysalis.barcode4j.servlet,
|
||||
org.krysalis.barcode4j.tools,
|
||||
org.krysalis.barcode4j.xalan,
|
||||
org.w3c.css.sac;version="1.3.0",
|
||||
org.w3c.css.sac.helpers;version="1.3.0",
|
||||
org.w3c.dom;version="3.0.0",
|
||||
|
|
|
@ -4,6 +4,5 @@ bin.includes = META-INF/,\
|
|||
lib/jasperreports-5.1.2.jar,\
|
||||
lib/jdt-compiler-3.1.1.jar,\
|
||||
lib/jasperreports-fonts-5.1.2.jar,\
|
||||
lib/barcode4j-2.1.jar,\
|
||||
lib/jackson-core-2.0.5.jar,\
|
||||
lib/xalan-2.7.1.jar
|
||||
|
|
Loading…
Reference in New Issue