I have written single page reports but I am now working on multiple page reports and have questions.
These reports have headers and footers with different content on the pages. The pages have different content for the headers, but the footers have the same content (file name and page number).
ISection has AddHeader(), AddFooter(), AddPage(), and AddPageBreak(). AddPage() returns a ISectionPaage object.
I am confused about how to add pages with different headers and using continuous page numbering in the footers.
I am looking for recommendations.
Hi Alf,
Well.. the page size is known to you. You can set it or get it from the section. And you can generally control the size of the objects you add to the page. Most have a Height and a Width. But as for suggestions, the only way you can really do this is one object at a time and keep track of where you are on the page. It's probably going to be pretty tough slogging through adding each element and determining whether it fits on the page or not. As far as I am aware there aren't any methods in the Documents engine to determine the amount of space left on the page, so you will probably need to keep track of that starting with the PageSize and then accounting for the margins, headers, etc.
I have been able to get the headers and footers working. If I use header.AddBand() and add all content to the band, then I can use band.measure() to get the size and set the height.
Now I get to the hard part of porting the old code. These are reports of data from lab instruments. The report pages have a header and footer and the content consists of some text tables and many charts. The code creates these tables and charts and then adds them to the report. Before each object is added to the report, it is determined if the object will fit on the current pdf page. If it will not, a new pdf page is added to the report.
I have some ideas on how to accomplish this, but if you have any ideas, please let me know.
Al
No, there is no reliably way to measure text in the document. You could, in theory, try to measure the same text on the screen in DotNet and then convert pixels to points. This is actually the way the WinGrid Document exporter does it. So you would use Graphics.MeasureString to measure the text using the screen's graphics and then convert the returned value (which is in pixels) into points. I don't think this is an exact measurement so you might have to add some padding just to be safe, but it works pretty well.
I am trying to use Flow and FlowColumn in my report. To set the column widths I need to measure the width of the strings. IText.Width returns a MaxWidth object, which does not give the string's width. Is there a way to determine a string's width in points?
What I am trying to accomplish is to have four columns in total in the header. Column1(label), Column2(value), Column3(label) - starts in middle of page, Column4(value).
To do this I need to know the width of the strings and the width of the header.
Thanks for any help.
Oh, sorry, I thought I mentioned it. All of the samples install optionally when you install the product. So if you installed the samples when you installed the controls, it's already on your hard drive. If you didn't install the sample, then I think you will have to run the installer again to get them.