|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Question about barcode sizesHello,
I am using iText to generate a sheet of product labels with a barcode on each label. To represent the labels I use a PdfPTable and set the cell sizes absolutely. When I try to fit a barcode 128 on a cell, I get into trouble because the code itself can be any number of characters long: when it is "000" the barcode is scaled up (somehow) to fit the cell's width, which makes it too high to fit in the cell and therefore is not visible. When the code is "ZZZZZZZZZZZZZZZZZZZZ" the barcode is scaled down so that it does fit in width but the height of the barcode is too small. I can set the bar (individual bar) width but this doesn't help me much since I don't know how many bars I will have (I only know the cell's width). I can set the bar's height but that also doesn't help me since it will be scaled to fit the barcode's width. Furthermore if I try to guess the smallest code I can have and set the bar height so that it fits, it makes it ridiculously thin in height when the largest codes are used. Ideally I would be able to generate a barcode for a given width and height so that larger codes "ZZZZZZZZZZZZZZZZZZZ" would have their bars high enough to fill the cell's height, and smaller codes "000" would use either smaller bar heights (so that scaling up still makes it fit both size constraints) or be centered if that produced bars too wide (due to the scaling up). I did try to create an image from the barcode and scale it, but I was unable to break the ratio so that the barcode height always fits the cell's height, regardless of the barcode's total width. Am I entirely missing something? Is there another way to produce what I need? Thanks for your help (and for iText). ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/ |
|
|
Re: Question about barcode sizesStephane Epardaud wrote:
> Am I entirely missing something? Is there another way to produce what I > need? Thanks for your help (and for iText). There are 4 ways to add a barcode/image to a PdfPTable. Let me quote from the (unpublished) Second Edition of "iText in Action" (it's also mentioned in the first edition), but I have the manuscript of the second edition in front of me, so that's easier: "When you create a PdfPCell with an Image as parameter, the default padding is 0 pt instead of 2 pt. With an extra parameter of type boolean, you can ask iText to scale the image so that it fits the width of the cell #2. By default, the value of this boolean is false and the image isn't scaled #1. This is a risk: if the image doesn't fit within the borders of the cell, it will exceed them and overlap with other cells. Adding an Image with addCell() will scale it, but the properties of the default cell will be used #3: the third poster in image 4.9 has a padding of 2 pt and it's bottom aligned. Finally, you can add an image as an element. The Image is scaled so that it fits the cell width for 100%, unless you change the width percentage with the method setWidthPercentage()." You're probably adding the barcode with addCell(). Try the alternatives to avoid scaling. -- This answer is provided by 1T3XT BVBA http://www.1t3xt.com/ - http://www.1t3xt.info ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/ |
|
|
Re: Question about barcode sizesOn Thu, Nov 05, 2009 at 11:47:01AM +0100, 1T3XT info wrote:
> There are 4 ways to add a barcode/image to a PdfPTable. > [...] > You're probably adding the barcode with addCell(). Try the alternatives > to avoid scaling. I was using cell.setImage() and needed to make it cell.setPhrase() to avoid the scaling. In order to have the width scaled but fill up the entire cell's height nonetheless I also scale the barcode image myself, but that means I disable the barcode's text so that it isn't scaled and print it myself underneath the barcode. Thanks for your help. It would be a lot easier however if there was a way to set the barcode's width and height so that it would fill the entire size without having to handle the barcode text outside. -- Stéphane Epardaud ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/ |
| Free embeddable forum powered by Nabble | Forum Help |