Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ahmed232323 opened this issue Nov 15, 2014 · 3 comments

Comments

@ahmed232323
Copy link

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

@dfaure-kdab
Copy link
Member

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.

@ahmed232323
Copy link
Author

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?

@dfaure-kdab
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants