aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-01-26 21:46:28 +0100
committerJay Berkenbilt <ejb@ql.org>2022-01-30 19:11:03 +0100
commitce740d987f1d129bc6b43071e95ee8f098caad05 (patch)
tree0ccae6f56e911288c9bde7a8b1dad72092b7f0ff /examples
parent2e4e25a9342b7c938748bc8bb795e406dbcbfc39 (diff)
downloadqpdf-ce740d987f1d129bc6b43071e95ee8f098caad05.tar.zst
Placeholder QPDFJob example
Diffstat (limited to 'examples')
-rw-r--r--examples/build.mk1
-rw-r--r--examples/pdf-job.cc48
2 files changed, 49 insertions, 0 deletions
diff --git a/examples/build.mk b/examples/build.mk
index 0d2c1132..5472fba5 100644
--- a/examples/build.mk
+++ b/examples/build.mk
@@ -8,6 +8,7 @@ BINS_examples = \
pdf-filter-tokens \
pdf-invert-images \
pdf-mod-info \
+ pdf-job \
pdf-name-number-tree \
pdf-npages \
pdf-overlay-page \
diff --git a/examples/pdf-job.cc b/examples/pdf-job.cc
new file mode 100644
index 00000000..238f44c0
--- /dev/null
+++ b/examples/pdf-job.cc
@@ -0,0 +1,48 @@
+#include <qpdf/QPDFJob.hh>
+#include <qpdf/QUtil.hh>
+
+#include <iostream>
+#include <cstring>
+
+// QXXXQ describe
+
+static char const* whoami = 0;
+
+#if 0 // QXXXQ
+static void usage(std::string const& msg)
+{
+ std::cerr << "Usage: " << whoami << " QXXXQ" << std::endl;
+ exit(2);
+}
+#endif
+
+int main(int argc, char* argv[])
+{
+ whoami = QUtil::getWhoami(argv[0]);
+
+ // For libtool's sake....
+ if (strncmp(whoami, "lt-", 3) == 0)
+ {
+ whoami += 3;
+ }
+
+ try
+ {
+ QPDFJob j;
+ j.config()
+ ->inputFile("/tmp/1.pdf")
+ ->outputFile("/tmp/2.pdf")
+ ->pages()
+ ->pageSpec(".", "1-z")
+ ->endPages()
+ ->qdf();
+ j.run();
+ }
+ catch (std::exception& e)
+ {
+ // QXXXQ catch usage, configerror, whatever we end up with separately
+ std::cerr << "exception: " << e.what() << std::endl;
+ return 2;
+ }
+ return 0;
+}