0
I have a barcode image being generated by barbecue
, this image is stored in an instance of Graphics2D
.
I wanted to know how I put this image in an instance of JRDesignImage
for it to be compiled and printed.
Code
//Criar o Design do relatório
JasperDesign report = new JasperDesign();
report.setName("teste");
report.setPageWidth((int)Math.round((90 * 72) / 25.4f)); //9cm
report.setPageHeight((int)Math.round((45 * 72) / 25.4f)); //4.5cm
report.setBottomMargin(0);
report.setTopMargin(0);
report.setLeftMargin(0);
report.setRightMargin(0);
report.setColumnWidth(report.getPageWidth());
//Criar a banda de detalhes
JRDesignBand band = new JRDesignBand();
band.setHeight(report.getPageHeight());
//Criar o componente de imagem
JRDesignImage imagem = new JRDesignImage(report);
imagem.setWidth((int)Math.round((50 * 72) / 25.4f));
imagem.setHeight((int)Math.round((40 * 72) / 25.4f));
imagem.setX((int)Math.round((20 * 72) / 25.4f));
imagem.setY((int)Math.round((5 * 72) / 25.4f));
Barcode barcode = BarcodeFactory.createUPCA("91231234567");
BufferedImage image = new BufferedImage(barcode.getWidth(), barcode.getHeight(), BufferedImage.TYPE_BYTE_GRAY);
Graphics2D g = (Graphics2D)image.getGraphics();
g.setBackground(Color.BLUE);
barcode.draw(g, 0, 0);
Here would be the point where I would pass the image, but I have no idea how to do it, I have looked at the documentation, but I had no light.
Are you wanting to mount Java programmatically (as I see in the example), or are you using ireport ? The reason for my question is that if you are in ireport, you do not need to keep doing this lot of calculations.
– wryel
I need to assemble programmatically, because the user will set the positions of the fields and size, plus the page size. With
Delphi
I set it up quiet, but I need a cross-platform version.– Roberto de Campos