GnuCash
Contact   Instructions
Bug 797401 - Invoice Reports need an overall page width set
Summary: Invoice Reports need an overall page width set
Status: RESOLVED FIXED
Alias: None
Product: GnuCash
Classification: Unclassified
Component: Reports (show other bugs)
Version: git-maint
Hardware: PC All
: Normal minor
Target Milestone: ---
Assignee: reports
QA Contact: reports
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-10 21:04 EDT by Adrien
Modified: 2019-12-07 08:30 EST (History)
5 users (show)

See Also:


Attachments
suggested patch result (24.21 KB, image/png)
2019-09-12 04:01 EDT, Christopher Lam
no flags Details
Example report with current main-table having unset width (34.15 KB, application/pdf)
2019-09-12 11:27 EDT, Adrien
no flags Details

Description Adrien 2019-09-10 21:04:27 EDT
Steps to reproduce:

1.Print an invoice
2.In Options, set some items in the header to the right
3.In Options, unselect several columns from being displayed
4.Observe that the entire invoice (including header) shrinks in width rather than filling the page.

Expected result:
Regardless of the visible columns, the entire page width should be used for at least the header and footer elements or everything gets scrunched

A simple quick-fix would be to change the following in the default CSS block in Options > Layout:

.entries-table > table { width: 100% }

to simply:

table { width: 100% }

This is because the entire page is contained in a table and this will force it (and others) to take up the full width they need.

A user can still specify an individual width for the entries-table and even center it if desired.

A better, long term solution would be to not to use tables for layout and only use them for tabular data. Floats are already being used for the header with their individual tables being contained in divs. Just ditch the table part of the HTML for those items and float (and size if needed) the divs.
Comment 1 Christopher Lam 2019-09-11 09:25:31 EDT
It would be good to have a diff between current invoice output and desired invoice output.

I'm sure you realised that the CSS input was offered as a free-form customisation option for anyone wishing custom invoices, and especially useful to merge the previous easy-invoice fancy-invoice printable-invoice separate reports.

However now I realise that if we modify the invoice elsewhere using divs or whatever, the CSS input now becomes a backward-compatibility nightmare :(
Comment 2 Geert Janssens 2019-09-11 10:58:51 EDT
(In reply to Christopher Lam from comment #1)
> It would be good to have a diff between current invoice output and desired
> invoice output.
> 
> I'm sure you realised that the CSS input was offered as a free-form
> customisation option for anyone wishing custom invoices, and especially
> useful to merge the previous easy-invoice fancy-invoice printable-invoice
> separate reports.
> 
> However now I realise that if we modify the invoice elsewhere using divs or
> whatever, the CSS input now becomes a backward-compatibility nightmare :(

Which means we should in principle only make such changes in major releases. Exceptions would be fixing major bugs.
Comment 3 Christopher Lam 2019-09-12 04:01:04 EDT
Created attachment 373387 [details]
suggested patch result

although patch fixes for A4 PDFs, it makes the report rather unattractive on screen.
Comment 4 Adrien 2019-09-12 11:26:45 EDT
I can mock up a semantic HTML skeleton, leaving the only table for the actual invoice data. (for the next major version)

Yes, I was aware of the CSS input, as that is how I played with it to find that solution. See this thread: https://lists.gnucash.org/pipermail/gnucash-user/2019-September/086848.html

Unfortunately John didn't send all those screenshots to the list, but I've added the one showing what happens when you remove columns and don't resize the table.

Per Comment 3, I see what you mean about screen viewing. If someone were using a large screen and had GC maximized it would look pretty silly. (though if they had a really long description, this would happen anyway)

There might be a solution for both but since my own stylesheets are modified, I'll need to play around with a test book.

Otherwise, maybe if someone wants to alter the default visible columns, they'll simply need to also play with custom CSS to make it look the way they want to. (thanks for that work by the way)
Comment 5 Adrien 2019-09-12 11:27:50 EDT
Created attachment 373388 [details]
Example report with current main-table having unset width
Comment 6 Christopher Lam 2019-10-01 12:36:31 EDT
I think the something like the following does the trick. And this is very very likely bad CSS. I cannot remember why .entries-table table needed the 100% in the first place. This must belong to master for reasons above.

@media print { table { width:100% } }
Comment 7 Christopher Lam 2019-11-19 07:09:56 EST
Adding the "@media print { table { width:100% } }" rule does fix this satisfactorily IMO.

Also IMO it *could* go to maint. Not many users will change CSS. It's nicer that the default report options show expanded table in portrait printouts.
Comment 8 Geert Janssens 2019-11-19 08:30:43 EST
Is there only one table in the invoice reports ? If not, do we really want all other tables to expand to full width as well ?

If the answer is two times yes, this is a proper fix. I especially appreciate it's only applied for print output.

Finally @Adrien - does webkit1 understand the @media switch ? As you are on Macos you are in a position to verify this. That is, if you add this snippet to the custom css, will the table expand properly only in the pdf output and not in the on-screen display ?
Comment 9 Christopher Lam 2019-11-19 09:15:36 EST
As it turns out, "@media print { .main-table > table { width:100% } }" is a more precise fix. It also works magically on Windows' libwebkitgtk1 -- both on File -> Export as PDF, and File->Export->Export Report, open in Firefox, and print.
Comment 10 Geert Janssens 2019-11-19 10:34:38 EST
Then that's even better :)
Comment 11 Adrien 2019-11-19 14:16:22 EST
This works for print:

@media print { .main-table > table { width:100% } }

It works with or without the .entries-table declaration. (because you're setting width higher up the cascade, it filters down)

This does not in all cases:

@media print { .main-table > table { width:100% } }

That works with the .entries-table rule for Export as PDF, (but not without it) and fails as Export Report to HTML.

Sadly I can't test an actual print for either rule as my physical printer is down at the moment.
Comment 12 Christopher Lam 2019-11-20 06:48:01 EST
Quote Jack Sparrow: "Now you're not making any sense at all"

I have never printed from gnucash reports at all but either removing or inserting .main-table doesn't seem to matter at all. I'd add it for the precision.
Comment 13 Adrien 2019-11-20 11:32:24 EST
Sorry, I realize now my copy/paste failed. What I meant to say was that:

This works for Export PDF and Export HTML:
@media print { table { width:100% } }

This does not:
@media print { .main-table > table { width:100% } }
Comment 14 Christopher Lam 2019-11-20 20:54:23 EST
Both types do work for me. What's the issue including .main-table?
Comment 15 Christopher Lam 2019-11-29 08:44:04 EST
I'd like to finalise this issue.
Could you let me know what's the issue with .main-table please?
Comment 16 Christopher Lam 2019-12-07 08:30:35 EST
I've merged in maint.
If there are further issues please reopen or file a new bug.

Note You need to log in before you can comment on or make changes to this bug.