Yves Goergen wrote: > Hi, > > How can I insert a horizontal bar graph/chart into a PdfPCell? The cell > has a border already but the graph should possibly keep a little margin > to the inner cell border.
A "padding". > Also, I'd need to determine the width of a > table cell so that I know how far my graph can go until it overflows. Then you need to define an absolute width for the table. Unless it's OK for the graph to be scaled to fit the cell. > The graph itself in a two-coloured bar. Green or orange up to 100% and > red for all that's above. > > I've searched the Web and browsed the API docs but couldn't find an easy > way to accomplish this. If it's that simple a graph, then using a PdfTemplate and some rectangle methods seems to be the easiest way. > I've seen that I can insert an Image into a cell but that only seems to > support existing raster images. Please read the documentation: http://itextpdf.com/book You can easily wrap a PdfTemplate inside an Image object. > I mean I could go create such an image > at ease from .NET classes, but how would I pass them to iText and would > they provide good printing quality at reasonable file size? Raster images could be "yucky". I'd go for PdfTemplate. I also wouldn't worry about the size of the graph. I'd let iText scale the graph (it's vector data anyway). > Here's an example of what I'm thinking of: > > +---------------+-----+-------------------+ (The table is 100 % of > | Topic 1 | 50 | XXXXX | the inner page width, > +---------------+-----+-------------------+ column widths are > | Topic 2 | 100 | XXXXXXXXXX | specified as fractions, > +---------------+-----+-------------------+ like [3, 1, 4].) > | Topic 3 | 130 | XXXXXXXXXX### | > +---------------+-----+-------------------+ > | Topic 4 | 280 | XXXXXXXXXX#####/# | > +---------------+-----+-------------------+ > > X is green or orange > # is red > / could be some break indicator, I'm using a big white slash in HTML > > I could live with 100 % being scaled to 50% of the cell width if that > makes it easier. Yep, definitely a task for PdfTempate. All the methods you need to draw the bars are listed in chapter 14 of the second edition of "iText in Action". -- This answer is provided by 1T3XT BVBA http://www.1t3xt.com/ - http://www.1t3xt.info ------------------------------------------------------------------------------ _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.itextpdf.com/book/ 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/
