Reputation: 39
I generate a barcode from a piece of text. When I decode the barcode, the text is no longer the same. The position of a colon changed.
i.e.
Name : RAMACHANDRA Roll No : 1001 Streem : MCA
But my requirement is below format
Name : RAMACHANDRA Roll No : 1001 Streem : MCA
This is my code
document.add(new Paragraph("NAME. :"+" "+"RAMACHANDRA",fontH));
document.add(new Paragraph("Roll No :"+" "+"1001",fontH));
document.add(new Paragraph("Streem :"+" "+"MCA",fontH));
document.add(new Paragraph());
code128.setGenerateChecksum(true);
code128.setCode("1001");
code128.setSize(8);
code128.setBaseline(10);
code128.setBarHeight(40f);
code128.setN(3);
code128.setX(2f);
document.add(code128.createImageWithBarcode(writer.getDirectContent(), null, null));
Upvotes: 0
Views: 115
Reputation: 9022
Putting the content in a table solves the problem.
Document document = new Document();
document.open();
final String[][] DATA = {{"NAME",":" +"Ramachandra"},{"RoLL No", ":" +"1001"}};
PdfPTable table = new PdfPTable(2);
table.addCell(DATA[0][0]);
table.addCell(DATA[0][1]);
table.addCell(DATA[1][0]);
table.addCell(DATA[1][1]);
document.close();
Upvotes: 2