summaryrefslogtreecommitdiffstats
path: root/printer.cpp
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2015-08-11 20:33:43 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2015-08-15 15:03:53 +0300
commit0ced68f15d57fe7487ec7286fb0e2358dd604092 (patch)
tree8c4f9c4c629e0a3499e6c1f401e4b5ab43e37d10 /printer.cpp
parentefe8dc9b5771fe51171060170ac002c82f29e317 (diff)
downloadsubsurface-0ced68f15d57fe7487ec7286fb0e2358dd604092.tar.gz
Printing: fix scrolling bug by adding extra padding
This bug occurs in "table" and "flowlayout" templates, it takes place when the size of the full web view to be rendered is not divisible by the size of the view port (Page size), This issue is fixed by adding extra padding to the bottom of the body so that the total body height is divisable by the view port size. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Diffstat (limited to 'printer.cpp')
-rw-r--r--printer.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/printer.cpp b/printer.cpp
index bce42c30d..635778042 100644
--- a/printer.cpp
+++ b/printer.cpp
@@ -168,6 +168,10 @@ void Printer::print()
}
int Pages;
if (divesPerPage == 0) {
+ // add extra padding at the bottom to pages with height not divisible by view port
+ int paddingBottom = pageSize.height() - (webView->page()->mainFrame()->contentsSize().height() % pageSize.height());
+ QString styleString = QString::fromUtf8("padding-bottom: ") + QString::number(paddingBottom) + "px;";
+ webView->page()->mainFrame()->findFirstElement("body").setAttribute("style", styleString);
Pages = ceil(webView->page()->mainFrame()->contentsSize().height() / (float)pageSize.height());
} else {
Pages = ceil(getTotalWork(printOptions) / (float)divesPerPage);