Hello
I am using IText to generate a PDF file with some text and an image with a
datamatrix barcode.
My code is the one (i am only testing the capabilties of IText for now)
BarcodeDatamatrix bcdm = new BarcodeDatamatrix();
bcdm.setOptions(BarcodeDatamatrix.DM_AUTO);
bcdm.setHeight(0);
bcdm.setWidth(0);
bcdm.generate(sValue);
com.lowagie.text.Image imgorderBarCode = bcdm.createImage( );
// Create a temporary PDF file
com.lowagie.text.Document document = new com.lowagie.text.Document(
PageSize.A4, 50, 50, 50, 50);
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream("c:/temp/tmp.pdf"));
document.open();
document.addSubject("This is the document subject.");
document.addTitle("This is the document title.");
document.addAuthor("Paulo is the author");
// Title of the document
Table tbl = new Table(1);
tbl.setBorderWidth(0);
tbl.setBorder(Rectangle.NO_BORDER);
tbl.getDefaultCell().setBorder(Rectangle.NO_BORDER);
tbl.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
tbl.setPadding(5);
tbl.setSpacing(5);
tbl.addCell("Document title");
tbl.addCell("");
tbl.setAutoFillEmptyCells(true);
document.add(tbl);
// Image of the barcode
PdfPTable bcTable = new PdfPTable(1);
bcTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
bcTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
bcTable.addCell(imgorderBarCode);
document.add(bcTable);
// Text of the document
PdfPTable pdfTable2 = new PdfPTable(2);
pdfTable2.getDefaultCell().setPadding(0f);
pdfTable2.getDefaultCell().setBorder(Rectangle.NO_BORDER);
pdfTable2.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
pdfTable2.setWidthPercentage(100f);
pdfTable2.addCell("");
pdfTable2.addCell("");
pdfTable2.addCell("NOM: ");
pdfTable2.addCell("Carvalho");
pdfTable2.addCell("PRENOM: ");
pdfTable2.addCell("Paulo");
pdfTable2.addCell("MATRICULE:");
pdfTable2.addCell("19771004123");
document.add(pdfTable2);
Everything works fine except the barcode showed in the document has a huge
size occupying almost all the page.
I tried to set the size using:
bcdm.setHeight(50);
bcdm.setWidth(50);
, but when i do that, the barcode does not appear in the document. The
barcode only appears in the document (but with a huge size) when i set the
height and width of the BarcodeDatamatrix object to 0.
Can you help me with the solution to have a document with a barcode with a
nice size?
Thanks
regards.
--
Paulo Carvalho
1 rue du Chateau
57710 Aumetz
France
greatesttravels.blogspot.com
www.sunofportugal.com
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/