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

Commit

Permalink
do not allow overriding the header/footer settings for cover pages
Browse files Browse the repository at this point in the history
This was discovered in #1676, where using a command-line like:

  wkhtmltopdf cover cover.html --header-html header.html page.html output.pdf

would override the settings for the cover page and not apply the
--header-html for the URL page.html. This may be unexpected behavior
for most users, but the manual clearly states that the options FOLLOW
the URL/file name, as in:

  cover <input url/file name> [PAGE OPTION]...
  (page)? <input url/file name> [PAGE OPTION]...

So, in the above example it actually means the following

  URL1: cover cover.html --header-html header.html
  URL2: page.html
  OUT:  output.pdf

To fix this, we parse the other page options for a cover page and
then set the header/footer settings to blank values to ensure that
they are not shown on a cover page.
  • Loading branch information
ashkulz committed Jul 4, 2014
1 parent 86ce2a1 commit affb35c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
v0.12.2 (unreleased)
--------------------
* **#1676**: do not allow overriding the header/footer settings for cover pages
* **#1758**: fix corrupt image when output is specified as "-" in wkhtmltoimage on Windows
* **#1772**: added variable 'isodate' for substitution in headers/footers
* **#1808**: fix [sitepage] and [sitepages] not working without HTML headers/footers
Expand Down
10 changes: 7 additions & 3 deletions src/pdf/pdfcommandlineparser.cc
Expand Up @@ -166,16 +166,20 @@ void PdfCommandLineParser::parseArguments(int argc, const char ** argv, bool fro
usage(stderr, false);
exit(1);
}
ps.page = QString::fromLocal8Bit(argv[arg]);
ps.page = QString::fromLocal8Bit(argv[arg++]);
// parse page options and then override the header/footer settings
for (;arg < argc;++arg) {
if (argv[arg][0] != '-' || argv[arg][1] == '\0' || defaultMode) break;
parseArg(sections, argc, argv, defaultMode, arg, (char*)&ps);
}

ps.header.left = ps.header.right = ps.header.center = "";
ps.footer.left = ps.footer.right = ps.footer.center = "";
ps.header.line = ps.footer.line = false;
ps.header.htmlUrl = ps.footer.htmlUrl = "";
ps.includeInOutline = false;

//Setup various cover settings here
++arg;
continue;
} else if (!strcmp(argv[arg],"toc")) {
++arg;
sections = page | toc;
Expand Down

0 comments on commit affb35c

Please sign in to comment.