From 0ced68f15d57fe7487ec7286fb0e2358dd604092 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Tue, 11 Aug 2015 20:33:43 +0200 Subject: [PATCH] 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 Signed-off-by: Gehad elrobey --- printer.cpp | 4 ++++ 1 file changed, 4 insertions(+) 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);