aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/pdf-filter-tokens.cc5
-rw-r--r--examples/pdf-invert-images.cc9
-rw-r--r--examples/pdf-mod-info.cc13
-rw-r--r--examples/pdf-overlay-page.cc6
-rw-r--r--examples/pdf-set-form-values.cc16
-rw-r--r--examples/pdf-split-pages.cc5
6 files changed, 16 insertions, 38 deletions
diff --git a/examples/pdf-filter-tokens.cc b/examples/pdf-filter-tokens.cc
index 59c85271..3d4bad8b 100644
--- a/examples/pdf-filter-tokens.cc
+++ b/examples/pdf-filter-tokens.cc
@@ -193,15 +193,12 @@ main(int argc, char* argv[])
pdf.processFile(infilename);
std::vector<QPDFPageObjectHelper> pages =
QPDFPageDocumentHelper(pdf).getAllPages();
- for (std::vector<QPDFPageObjectHelper>::iterator iter = pages.begin();
- iter != pages.end();
- ++iter) {
+ for (auto& page: pages) {
// Attach two token filters to each page of this file.
// When the file is written, or when the pages' contents
// are retrieved in any other way, the filters will be
// applied. See comments on the filters for additional
// details.
- QPDFPageObjectHelper& page(*iter);
page.addContentTokenFilter(
std::shared_ptr<QPDFObjectHandle::TokenFilter>(
new StringReverser));
diff --git a/examples/pdf-invert-images.cc b/examples/pdf-invert-images.cc
index bd36f33f..b784c8e3 100644
--- a/examples/pdf-invert-images.cc
+++ b/examples/pdf-invert-images.cc
@@ -131,14 +131,11 @@ main(int argc, char* argv[])
// For each page...
std::vector<QPDFPageObjectHelper> pages =
QPDFPageDocumentHelper(qpdf).getAllPages();
- for (std::vector<QPDFPageObjectHelper>::iterator iter = pages.begin();
- iter != pages.end();
- ++iter) {
- QPDFPageObjectHelper& page(*iter);
+ for (auto& page: pages) {
// Get all images on the page.
std::map<std::string, QPDFObjectHandle> images = page.getImages();
- for (auto& iter2: images) {
- QPDFObjectHandle& image = iter2.second;
+ for (auto& iter: images) {
+ QPDFObjectHandle& image = iter.second;
QPDFObjectHandle image_dict = image.getDict();
QPDFObjectHandle color_space = image_dict.getKey("/ColorSpace");
QPDFObjectHandle bits_per_component =
diff --git a/examples/pdf-mod-info.cc b/examples/pdf-mod-info.cc
index 425a25ba..2b8e3c47 100644
--- a/examples/pdf-mod-info.cc
+++ b/examples/pdf-mod-info.cc
@@ -132,10 +132,7 @@ main(int argc, char* argv[])
QPDFObjectHandle filetrailer = file.getTrailer();
QPDFObjectHandle fileinfo;
- for (std::map<std::string, std::string>::const_iterator it =
- Keys.begin();
- Keys.end() != it;
- ++it) {
+ for (auto const& it: Keys) {
if (!fileinfo.isInitialized()) {
if (filetrailer.hasKey("/Info")) {
QTC::TC("examples", "pdf-mod-info has info");
@@ -146,12 +143,12 @@ main(int argc, char* argv[])
filetrailer.replaceKey("/Info", fileinfo);
}
}
- if (it->second == "") {
- fileinfo.removeKey(it->first);
+ if (it.second == "") {
+ fileinfo.removeKey(it.first);
} else {
- QPDFObjectHandle elt = fileinfo.newString(it->second);
+ QPDFObjectHandle elt = fileinfo.newString(it.second);
elt.makeDirect();
- fileinfo.replaceKey(it->first, elt);
+ fileinfo.replaceKey(it.first, elt);
}
}
QPDFWriter w(file, fl_tmp.c_str());
diff --git a/examples/pdf-overlay-page.cc b/examples/pdf-overlay-page.cc
index 64a8d48f..f9603d9c 100644
--- a/examples/pdf-overlay-page.cc
+++ b/examples/pdf-overlay-page.cc
@@ -42,11 +42,7 @@ stamp_page(char const* infile, char const* stampfile, char const* outfile)
// For each page...
std::vector<QPDFPageObjectHelper> pages =
QPDFPageDocumentHelper(inpdf).getAllPages();
- for (std::vector<QPDFPageObjectHelper>::iterator iter = pages.begin();
- iter != pages.end();
- ++iter) {
- QPDFPageObjectHelper& ph = *iter;
-
+ for (auto& ph: pages) {
// Find a unique resource name for the new form XObject
QPDFObjectHandle resources = ph.getAttribute("/Resources", true);
int min_suffix = 1;
diff --git a/examples/pdf-set-form-values.cc b/examples/pdf-set-form-values.cc
index 10394c7b..c28149ad 100644
--- a/examples/pdf-set-form-values.cc
+++ b/examples/pdf-set-form-values.cc
@@ -52,23 +52,17 @@ main(int argc, char* argv[])
QPDFAcroFormDocumentHelper afdh(qpdf);
QPDFPageDocumentHelper pdh(qpdf);
std::vector<QPDFPageObjectHelper> pages = pdh.getAllPages();
- for (std::vector<QPDFPageObjectHelper>::iterator page_iter =
- pages.begin();
- page_iter != pages.end();
- ++page_iter) {
+ for (auto const& page: pages) {
// Get all widget annotations for each page. Widget
// annotations are the ones that contain the details of
// what's in a form field.
std::vector<QPDFAnnotationObjectHelper> annotations =
- afdh.getWidgetAnnotationsForPage(*page_iter);
- for (std::vector<QPDFAnnotationObjectHelper>::iterator annot_iter =
- annotations.begin();
- annot_iter != annotations.end();
- ++annot_iter) {
+ afdh.getWidgetAnnotationsForPage(page);
+ for (auto& annot: annotations) {
// For each annotation, find its associated field. If
// it's a text field, set its value.
QPDFFormFieldObjectHelper ffh =
- afdh.getFieldForAnnotation(*annot_iter);
+ afdh.getFieldForAnnotation(annot);
if (ffh.getFieldType() == "/Tx") {
// Set the value. Passing false as the second
// value prevents qpdf from setting
@@ -81,7 +75,7 @@ main(int argc, char* argv[])
// additional details, please see comments in
// QPDFFormFieldObjectHelper.hh for this method.
ffh.setV(value, false);
- ffh.generateAppearance(*annot_iter);
+ ffh.generateAppearance(annot);
}
}
}
diff --git a/examples/pdf-split-pages.cc b/examples/pdf-split-pages.cc
index a8e65260..150de0df 100644
--- a/examples/pdf-split-pages.cc
+++ b/examples/pdf-split-pages.cc
@@ -27,10 +27,7 @@ process(char const* whoami, char const* infile, std::string outprefix)
int pageno_len =
QIntC::to_int(QUtil::uint_to_string(pages.size()).length());
int pageno = 0;
- for (std::vector<QPDFPageObjectHelper>::iterator iter = pages.begin();
- iter != pages.end();
- ++iter) {
- QPDFPageObjectHelper& page(*iter);
+ for (auto& page: pages) {
std::string outfile =
outprefix + QUtil::int_to_string(++pageno, pageno_len) + ".pdf";
QPDF outpdf;