summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKris Jurka <jurka@ejurka.com>2019-12-04 22:51:16 -0800
committerAlbert Astals Cid <tsdgeos@yahoo.es>2019-12-05 23:26:44 +0000
commitd8da6fd3b4c92651092d0a73f54b244bb45e1711 (patch)
tree89437c4f277e7334266b7014e9d8759a0f87ec76
parent311db0b2de9a63d240d19bb90ba95a78f7856388 (diff)
pdftoxxx: error out when even/odd selects 0 pages
When page selection options and/or document length result in planned output of a single page, further even/odd page selection can then result in no pages being output. Error out instead of producing no output which is confusing to the user. Closes: https://gitlab.freedesktop.org/poppler/poppler/issues/815
-rw-r--r--utils/pdftocairo.cc13
-rw-r--r--utils/pdftoppm.cc11
2 files changed, 21 insertions, 3 deletions
diff --git a/utils/pdftocairo.cc b/utils/pdftocairo.cc
index 04b9f047..b096cad3 100644
--- a/utils/pdftocairo.cc
+++ b/utils/pdftocairo.cc
@@ -1170,6 +1170,16 @@ int main(int argc, char *argv[]) {
exit(99);
}
+ // If our page range selection and document size indicate we're only
+ // outputting a single page, ensure that even/odd page selection doesn't
+ // filter out that single page.
+ if (firstPage == lastPage &&
+ ((printOnlyEven && firstPage % 2 == 0) ||
+ (printOnlyOdd && firstPage % 2 == 1))) {
+ fprintf(stderr, "Invalid even/odd page selection, no pages match criteria.\n");
+ exit(99);
+ }
+
if (singleFile && firstPage < lastPage) {
if (!quiet) {
fprintf(stderr,
@@ -1197,9 +1207,6 @@ int main(int argc, char *argv[]) {
}
#endif
- // Make sure firstPage is always used so that beginDocument() is called
- if ((printOnlyEven && firstPage % 2 == 0) || (printOnlyOdd && firstPage % 2 == 1))
- firstPage++;
cairoOut = new CairoOutputDev();
cairoOut->startDoc(doc);
diff --git a/utils/pdftoppm.cc b/utils/pdftoppm.cc
index aac1f743..b14312fe 100644
--- a/utils/pdftoppm.cc
+++ b/utils/pdftoppm.cc
@@ -517,6 +517,17 @@ int main(int argc, char *argv[]) {
goto err1;
}
+ // If our page range selection and document size indicate we're only
+ // outputting a single page, ensure that even/odd page selection doesn't
+ // filter out that single page.
+ if (firstPage == lastPage &&
+ ((printOnlyEven && firstPage % 2 == 0) ||
+ (printOnlyOdd && firstPage % 2 == 1))) {
+ fprintf(stderr, "Invalid even/odd page selection, no pages match criteria.\n");
+ goto err1;
+ }
+
+
if (singleFile && firstPage < lastPage) {
if (!quiet) {
fprintf(stderr,