KDReports icon indicating copy to clipboard operation
KDReports copied to clipboard

specifing report header for first page, an empty space (equals to header) appears on all pages of report

Open ahmed232323 opened this issue 9 years ago • 3 comments

I found a bug on KD Report (may be a miss use of API), and I want to report it, or at least some one help me fixed it .

The issue is when you specify report header only for first page, an empty space (equals to header) appears on all pages of report.

attaching you an image that specify problem much clearly. note: i have header on first page only, and footer on last page only

KD reports 1.4 Qt 5.3.0 mingw32 win7 x64 kdreport

ahmed232323 avatar Nov 15 '14 17:11 ahmed232323

You are right, but this cannot be changed. The content document (the main text, excluding headers and footers) is laid out using QTextDocument, which knows about a single "page size". So it doesn't support having a first page with a smaller size than the following pages.

In your case the solution seems quite simple: the things that should appear on the first page and that are currently in a "first page header" can just be added directly to the first page, without using the header feature.

For the last page it might be a bit more tricky though, if it should be bottom aligned rather than directly under the end of the main document. We can talk about a "align to bottom of page" feature, at least that's doable, unlike pages with a different content size.

dfaure-kdab avatar Dec 29 '14 18:12 dfaure-kdab

it's really nice solution to add first page header "things" before report contents, this fix 50% of my issue :-) . for last page footer, you mentioned that the report content is laid out using QTextDocument, is it possible to calculate height of KDReports::Element? to be aligned into bottom of the page?

ahmed232323 avatar Jan 05 '15 05:01 ahmed232323

You would need not only the height of the element, but also the height of the document contents as of "before inserting the footer", no? (in order to insert a vertical space of the difference between the two).

More precisely vspace = page_content_height - bottom_of_current_text - element_height...

(where page content height is without headers and footers)

We could expose the first two in the Report class, but finding out the height of an element before inserting it into the text document is quite difficult. The alternative is to "go back" and insert the vspace above the "footer" after inserting that footer, a bit like updateTextValue works. (but not exactly, so it would be a new method called updateVerticalSpacing).

Unless your last page is really just that bottom-aligned footer, nothing above it? Then bottom_of_current_text is zero.

dfaure-kdab avatar Jan 05 '15 10:01 dfaure-kdab