據我所知,條形碼本身不能旋轉(iReport沒有該屬性,在Java類中也沒有Barbecue Barcode)。我見過一些例子,但它們是不完整的,我不知道如何使用它們,例如:如何在Java/iReport中旋轉條形碼?
public class BarbecueRenderer extends JRAbstractSvgRenderer
{
private boolean rotate;
private Barcode barcode = null;
public BarbecueRenderer(Barcode barcode)
{
this(barcode, false);
}
public BarbecueRenderer(Barcode barcode, boolean rotate)
{
this.barcode = barcode;
this.rotate = rotate;
}
// What should I use as the grx and rectangle objects?
public void render(Graphics2D grx, Rectangle2D rectangle)
{
if (barcode != null)
{
Graphics2D graphics = (Graphics2D) grx.create();
graphics.translate(rectangle.getX(), rectangle.getY());
if (rotate)
{
graphics.translate(barcode.getBounds().getHeight(), 0);
graphics.rotate(Math.PI/2);
}
barcode.draw(graphics, 0, 0);
}
}
}
我需要的是這樣的:
Barcode barcode = BarcodeFactory.createCode39("128", false);
// rotate the barcode
File f = new File ("c:\\barcode.jpg");
BarcodeImageHandler.saveJPEG(barcode, f);
http://www.barcodelib.com/java_barcode/main.html – 2010-10-25 12:44:45
忘了提,需要做的是免費的:) – Andrija 2010-10-25 12:53:28