Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Different margins for the cover page #3692

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/wkhtmltox/pdfsettings.hh
Expand Up @@ -202,6 +202,8 @@ struct DLL_PUBLIC PdfObject {

bool isTableOfContent;

bool isCover;

QString tocXsl;

QString get(const char * name);
Expand Down
16 changes: 16 additions & 0 deletions src/lib/pdfconverter.cc
Expand Up @@ -991,10 +991,26 @@ void PdfConverterPrivate::printDocument() {
progressString = "Preparing";
emit out.progressChanged(0);

qreal leftMargin, topMargin, rightMargin, bottomMargin;
printer->getPageMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin, settings.margin.left.second);

for (int cc_=0; cc_ < cc; ++cc_) {
pageNumber=1;
for (int d=0; d < objects.size(); ++d) {
if (objects[d].settings.isCover) {
painter->save();
printer->setPageMargins(leftMargin, 0, rightMargin, 0, settings.margin.left.second);
painter->translate(0, -topMargin * printer->height() / printer->heightMM());
painter->translate(0, printer->height() / printer->heightMM());
}

beginPrintObject(objects[d]);

if (objects[d].settings.isCover) {
printer->setPageMargins(leftMargin, topMargin, rightMargin, bottomMargin, settings.margin.left.second);
painter->restore();
}

// XXX: In some cases nothing gets loaded at all,
// so we would get no webPrinter instance.
int pageCount = webPrinter != 0 ? webPrinter->pageCount() : 0;
Expand Down
2 changes: 2 additions & 0 deletions src/lib/pdfsettings.cc
Expand Up @@ -162,6 +162,7 @@ struct DLL_LOCAL ReflectImpl<PdfObject>: public ReflectClass {
WKHTMLTOPDF_REFLECT(includeInOutline);
WKHTMLTOPDF_REFLECT(pagesCount);
WKHTMLTOPDF_REFLECT(isTableOfContent);
WKHTMLTOPDF_REFLECT(isCover);
WKHTMLTOPDF_REFLECT(tocXsl);
}
};
Expand Down Expand Up @@ -405,6 +406,7 @@ PdfObject::PdfObject():
includeInOutline(true),
pagesCount(true),
isTableOfContent(false),
isCover(false),
tocXsl("") {};

QString PdfGlobal::get(const char * name) {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/pdfsettings.hh
Expand Up @@ -202,6 +202,8 @@ struct DLL_PUBLIC PdfObject {

bool isTableOfContent;

bool isCover;

QString tocXsl;

QString get(const char * name);
Expand Down
1 change: 1 addition & 0 deletions src/pdf/pdfcommandlineparser.cc
Expand Up @@ -178,6 +178,7 @@ void PdfCommandLineParser::parseArguments(int argc, const char ** argv, bool fro
ps.header.line = ps.footer.line = false;
ps.header.htmlUrl = ps.footer.htmlUrl = "";
ps.includeInOutline = false;
ps.isCover = true;

continue;
} else if (!strcmp(argv[arg],"toc")) {
Expand Down