That's a matter of image scaling. There are examples in the tutorial and
the book. You are also advised to use PdfPTable instead of Table.

Paulo 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Paulo Carvalho
> Sent: Wednesday, February 06, 2008 11:01 AM
> To: itext-questions@lists.sourceforge.net
> Subject: [iText-questions] Barcode image size
> 
> 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 
> 


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter 
informação confidencial ou legalmente protegida. A incorrecta transmissão desta 
mensagem não significa a perca de confidencialidade. Se esta mensagem for 
recebida por engano, por favor envie-a de volta para o remetente e apague-a do 
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de 
usar, revelar ou distribuir qualquer parte desta mensagem. 

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain 
confidential or legally protected information. The incorrect transmission of 
this message does not mean the loss of its confidentiality. If this message is 
received by mistake, please send it back to the sender and delete it from your 
system immediately. It is forbidden to any person who is not the intended 
receiver to use, distribute or copy any part of this message.


-------------------------------------------------------------------------
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/

Reply via email to