Home
Analytics
PDF and barcode generation
IvanHoe
I'm new on the BIRT designing world.<br />
<br />
I'm using BIRT 2.5.1 and comes with iText 1.54 and I'd like to use iText barcode generation capabilities in my web app.<br />
<br />
I can obtain a PDF "subreport" or piece if you want to call it something but I'm unable to display it on my report design. It displays once deployed ""Current report item is not supported in this report format"...<br />
<br />
This is what I have on my servlet:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
SubReport folio = new SubReport();
ByteArrayOutputStream baos = folio.getFolioBC("123456");
byte[] bytes = baos.toByteArray();
task.getAppContext().put("imageBarcode", bytes);
</pre>
<br />
That code gets a ByteArray that starts with %PDF... and so on, so I assume it is a whole PDF with the barcode I need.<br />
<br />
The SubReport class that outputs the ByteArrays is as follows:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
public ByteArrayOutputStream getFolioBC (String folio) throws IOException, DocumentException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, baos);
document.open();
PdfContentByte cb = writer.getDirectContent();
//Barcode 3 of 9 extended
Barcode39 code39ext = new Barcode39();
code39ext.setCode(folio);
code39ext.setStartStopText(false);
code39ext.setExtended(true);
document.add(code39ext.createImageWithBarcode(cb, null, null));
document.close();
return baos;
}
</pre>
<br />
Can you suggest me a way in with I don't have to depend on barcode fonts?<br />
<br />
Hope to hear from you.
Find more posts tagged with
Comments
Adam201104
Hi,<br />
<br />
You can add BIRT Barcode Plugin to generate Barcode in BIRT reports.You can try BIRT Barcode Plugin.You can visit <a class='bbc_url' href='
http://www.onbarcode.com/products/birt_barcode/'>BIRT
Barcode Generator</a> and also <a class='bbc_url' href='
http://www.onbarcode.com/tutorial/java-barcode-eclipse-birt.html'>Eclipse
BIRT Barcode Generation Guide</a>