aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-02-08 15:18:08 +0100
committerJay Berkenbilt <ejb@ql.org>2022-02-08 17:51:15 +0100
commitcb769c62e55599e9f980001830bc61d9fcaa64a9 (patch)
tree0bf980c385a61cbc8720cf990762ffc1200f9d6a /examples
parent716381f65a2b2dc72f8da2426ba71aeab02c507f (diff)
downloadqpdf-cb769c62e55599e9f980001830bc61d9fcaa64a9.tar.zst
WHITESPACE ONLY -- expand tabs in source code
This comment expands all tabs using an 8-character tab-width. You should ignore this commit when using git blame or use git blame -w. In the early days, I used to use tabs where possible for indentation, since emacs did this automatically. In recent years, I have switched to only using spaces, which means qpdf source code has been a mixture of spaces and tabs. I have avoided cleaning this up because of not wanting gratuitous whitespaces change to cloud the output of git blame, but I changed my mind after discussing with users who view qpdf source code in editors/IDEs that have other tab widths by default and in light of the fact that I am planning to start applying automatic code formatting soon.
Diffstat (limited to 'examples')
-rw-r--r--examples/pdf-attach-file.cc8
-rw-r--r--examples/pdf-bookmarks.cc144
-rw-r--r--examples/pdf-c-objects.c30
-rw-r--r--examples/pdf-count-strings.cc14
-rw-r--r--examples/pdf-create.cc14
-rw-r--r--examples/pdf-custom-filter.cc6
-rw-r--r--examples/pdf-double-page-size.cc82
-rw-r--r--examples/pdf-filter-tokens.cc14
-rw-r--r--examples/pdf-invert-images.cc118
-rw-r--r--examples/pdf-linearize.c32
-rw-r--r--examples/pdf-mod-info.cc252
-rw-r--r--examples/pdf-name-number-tree.cc10
-rw-r--r--examples/pdf-npages.cc26
-rw-r--r--examples/pdf-overlay-page.cc12
-rw-r--r--examples/pdf-parse-content.cc14
-rw-r--r--examples/pdf-set-form-values.cc22
-rw-r--r--examples/pdf-split-pages.cc16
-rw-r--r--examples/qpdf-job.cc2
-rw-r--r--examples/qpdfjob-c.c8
-rw-r--r--examples/qtest/bookmarks.test46
-rw-r--r--examples/qtest/count-strings.test4
-rw-r--r--examples/qtest/create.test4
-rw-r--r--examples/qtest/double-page-size.test14
-rw-r--r--examples/qtest/filter-tokens.test8
-rw-r--r--examples/qtest/invert-images.test14
-rw-r--r--examples/qtest/linearize.test10
-rw-r--r--examples/qtest/mod-info.test90
-rw-r--r--examples/qtest/name-number-tree.test10
-rw-r--r--examples/qtest/npages.test14
-rw-r--r--examples/qtest/overlay-page.test16
-rw-r--r--examples/qtest/parse-content.test6
-rw-r--r--examples/qtest/pdf-split-pages.test12
-rw-r--r--examples/qtest/qpdf-job.test4
-rw-r--r--examples/qtest/qpdfjob-c.test8
-rw-r--r--examples/qtest/set-form-values.test8
35 files changed, 546 insertions, 546 deletions
diff --git a/examples/pdf-attach-file.cc b/examples/pdf-attach-file.cc
index decc742f..5f60bdb5 100644
--- a/examples/pdf-attach-file.cc
+++ b/examples/pdf-attach-file.cc
@@ -150,7 +150,7 @@ int main(int argc, char* argv[])
// For libtool's sake....
if (strncmp(whoami, "lt-", 3) == 0)
{
- whoami += 3;
+ whoami += 3;
}
char const* infilename = 0;
@@ -216,9 +216,9 @@ int main(int argc, char* argv[])
}
catch (std::exception &e)
{
- std::cerr << whoami << " exception: "
- << e.what() << std::endl;
- exit(2);
+ std::cerr << whoami << " exception: "
+ << e.what() << std::endl;
+ exit(2);
}
return 0;
diff --git a/examples/pdf-bookmarks.cc b/examples/pdf-bookmarks.cc
index d4501728..e343c541 100644
--- a/examples/pdf-bookmarks.cc
+++ b/examples/pdf-bookmarks.cc
@@ -20,16 +20,16 @@ static std::map<QPDFObjGen, int> page_map;
void usage()
{
std::cerr << "Usage: " << whoami << " [options] file.pdf [password]"
- << std::endl
- << "Options:" << std::endl
- << " --numbers give bookmarks outline-style numbers"
- << std::endl
- << " --lines draw lines to show bookmark hierarchy"
- << std::endl
- << " --show-open indicate whether a bookmark is initially open"
- << std::endl
- << " --show-targets show target if possible"
- << std::endl;
+ << std::endl
+ << "Options:" << std::endl
+ << " --numbers give bookmarks outline-style numbers"
+ << std::endl
+ << " --lines draw lines to show bookmark hierarchy"
+ << std::endl
+ << " --show-open indicate whether a bookmark is initially open"
+ << std::endl
+ << " --show-targets show target if possible"
+ << std::endl;
exit(2);
}
@@ -37,14 +37,14 @@ void print_lines(std::vector<int>& numbers)
{
for (unsigned int i = 0; i < numbers.size() - 1; ++i)
{
- if (numbers.at(i))
- {
- std::cout << "| ";
- }
- else
- {
- std::cout << " ";
- }
+ if (numbers.at(i))
+ {
+ std::cout << "| ";
+ }
+ else
+ {
+ std::cout << " ";
+ }
}
}
@@ -54,10 +54,10 @@ void generate_page_map(QPDF& qpdf)
std::vector<QPDFPageObjectHelper> pages = dh.getAllPages();
int n = 0;
for (std::vector<QPDFPageObjectHelper>::iterator iter = pages.begin();
- iter != pages.end(); ++iter)
+ iter != pages.end(); ++iter)
{
- QPDFObjectHandle oh = (*iter).getObjectHandle();
- page_map[oh.getObjGen()] = ++n;
+ QPDFObjectHandle oh = (*iter).getObjectHandle();
+ page_map[oh.getObjGen()] = ++n;
}
}
@@ -163,50 +163,50 @@ int main(int argc, char* argv[])
// For libtool's sake....
if (strncmp(whoami, "lt-", 3) == 0)
{
- whoami += 3;
+ whoami += 3;
}
if ((argc == 2) && (strcmp(argv[1], "--version") == 0))
{
- std::cout << whoami << " version 1.5" << std::endl;
- exit(0);
+ std::cout << whoami << " version 1.5" << std::endl;
+ exit(0);
}
int arg;
for (arg = 1; arg < argc; ++arg)
{
- if (argv[arg][0] == '-')
- {
- if (strcmp(argv[arg], "--numbers") == 0)
- {
- style = st_numbers;
- }
- else if (strcmp(argv[arg], "--lines") == 0)
- {
- style = st_lines;
- }
- else if (strcmp(argv[arg], "--show-open") == 0)
- {
- show_open = true;
- }
- else if (strcmp(argv[arg], "--show-targets") == 0)
- {
- show_targets = true;
- }
- else
- {
- usage();
- }
- }
- else
- {
- break;
- }
+ if (argv[arg][0] == '-')
+ {
+ if (strcmp(argv[arg], "--numbers") == 0)
+ {
+ style = st_numbers;
+ }
+ else if (strcmp(argv[arg], "--lines") == 0)
+ {
+ style = st_lines;
+ }
+ else if (strcmp(argv[arg], "--show-open") == 0)
+ {
+ show_open = true;
+ }
+ else if (strcmp(argv[arg], "--show-targets") == 0)
+ {
+ show_targets = true;
+ }
+ else
+ {
+ usage();
+ }
+ }
+ else
+ {
+ break;
+ }
}
if (arg >= argc)
{
- usage();
+ usage();
}
char const* filename = argv[arg++];
@@ -214,38 +214,38 @@ int main(int argc, char* argv[])
if (arg < argc)
{
- password = argv[arg++];
+ password = argv[arg++];
}
if (arg != argc)
{
- usage();
+ usage();
}
try
{
- QPDF qpdf;
- qpdf.processFile(filename, password);
+ QPDF qpdf;
+ qpdf.processFile(filename, password);
QPDFOutlineDocumentHelper odh(qpdf);
- if (odh.hasOutlines())
- {
- std::vector<int> numbers;
- if (show_targets)
- {
- generate_page_map(qpdf);
- }
- extract_bookmarks(odh.getTopLevelOutlines(), numbers);
- }
- else
- {
- std::cout << filename << " has no bookmarks" << std::endl;
- }
+ if (odh.hasOutlines())
+ {
+ std::vector<int> numbers;
+ if (show_targets)
+ {
+ generate_page_map(qpdf);
+ }
+ extract_bookmarks(odh.getTopLevelOutlines(), numbers);
+ }
+ else
+ {
+ std::cout << filename << " has no bookmarks" << std::endl;
+ }
}
catch (std::exception &e)
{
- std::cerr << whoami << " processing file " << filename << ": "
- << e.what() << std::endl;
- exit(2);
+ std::cerr << whoami << " processing file " << filename << ": "
+ << e.what() << std::endl;
+ exit(2);
}
return 0;
diff --git a/examples/pdf-c-objects.c b/examples/pdf-c-objects.c
index d800b8af..c616997a 100644
--- a/examples/pdf-c-objects.c
+++ b/examples/pdf-c-objects.c
@@ -58,20 +58,20 @@ int main(int argc, char* argv[])
if ((p = strrchr(argv[0], '/')) != NULL)
{
- whoami = p + 1;
+ whoami = p + 1;
}
else if ((p = strrchr(argv[0], '\\')) != NULL)
{
- whoami = p + 1;
+ whoami = p + 1;
}
else
{
- whoami = argv[0];
+ whoami = argv[0];
}
if (argc != 4)
{
- usage();
+ usage();
}
infile = argv[1];
@@ -80,34 +80,34 @@ int main(int argc, char* argv[])
if (((qpdf_read(qpdf, infile, password) & QPDF_ERRORS) == 0) &&
modify_file(qpdf) &&
- ((qpdf_init_write(qpdf, outfile) & QPDF_ERRORS) == 0))
+ ((qpdf_init_write(qpdf, outfile) & QPDF_ERRORS) == 0))
{
/* Use static ID for testing only. For production, a
* non-static ID is used. See also
* qpdf_set_deterministic_ID. */
- qpdf_set_static_ID(qpdf, QPDF_TRUE); /* for testing only */
- qpdf_write(qpdf);
+ qpdf_set_static_ID(qpdf, QPDF_TRUE); /* for testing only */
+ qpdf_write(qpdf);
}
while (qpdf_more_warnings(qpdf))
{
- warnings = 1;
- printf("warning: %s\n",
- qpdf_get_error_full_text(qpdf, qpdf_next_warning(qpdf)));
+ warnings = 1;
+ printf("warning: %s\n",
+ qpdf_get_error_full_text(qpdf, qpdf_next_warning(qpdf)));
}
if (qpdf_has_error(qpdf))
{
- errors = 1;
- printf("error: %s\n",
- qpdf_get_error_full_text(qpdf, qpdf_get_error(qpdf)));
+ errors = 1;
+ printf("error: %s\n",
+ qpdf_get_error_full_text(qpdf, qpdf_get_error(qpdf)));
}
qpdf_cleanup(&qpdf);
if (errors)
{
- return 2;
+ return 2;
}
else if (warnings)
{
- return 3;
+ return 3;
}
return 0;
diff --git a/examples/pdf-count-strings.cc b/examples/pdf-count-strings.cc
index 3b78ac76..600042f7 100644
--- a/examples/pdf-count-strings.cc
+++ b/examples/pdf-count-strings.cc
@@ -20,7 +20,7 @@ static char const* whoami = 0;
void usage()
{
std::cerr << "Usage: " << whoami << " infile" << std::endl
- << "Applies token filters to infile"
+ << "Applies token filters to infile"
<< std::endl;
exit(2);
}
@@ -78,19 +78,19 @@ int main(int argc, char* argv[])
// For libtool's sake....
if (strncmp(whoami, "lt-", 3) == 0)
{
- whoami += 3;
+ whoami += 3;
}
if (argc != 2)
{
- usage();
+ usage();
}
char const* infilename = argv[1];
try
{
- QPDF pdf;
- pdf.processFile(infilename);
+ QPDF pdf;
+ pdf.processFile(infilename);
std::vector<QPDFPageObjectHelper> pages =
QPDFPageDocumentHelper(pdf).getAllPages();
int pageno = 0;
@@ -123,8 +123,8 @@ int main(int argc, char* argv[])
}
catch (std::exception& e)
{
- std::cerr << whoami << ": " << e.what() << std::endl;
- exit(2);
+ std::cerr << whoami << ": " << e.what() << std::endl;
+ exit(2);
}
return 0;
diff --git a/examples/pdf-create.cc b/examples/pdf-create.cc
index 8d1e8ee6..f0e86a52 100644
--- a/examples/pdf-create.cc
+++ b/examples/pdf-create.cc
@@ -31,7 +31,7 @@ class ImageProvider: public QPDFObjectHandle::StreamDataProvider
std::string const& filter);
virtual ~ImageProvider();
virtual void provideStreamData(int objid, int generation,
- Pipeline* pipeline);
+ Pipeline* pipeline);
size_t getWidth() const;
size_t getHeight() const;
@@ -142,7 +142,7 @@ ImageProvider::provideStreamData(int objid, int generation,
void usage()
{
std::cerr << "Usage: " << whoami << " filename" << std::endl
- << "Creates a simple PDF and writes it to filename" << std::endl;
+ << "Creates a simple PDF and writes it to filename" << std::endl;
exit(2);
}
@@ -424,22 +424,22 @@ int main(int argc, char* argv[])
// For libtool's sake....
if (strncmp(whoami, "lt-", 3) == 0)
{
- whoami += 3;
+ whoami += 3;
}
if (argc != 2)
{
- usage();
+ usage();
}
char const* filename = argv[1];
try
{
- create_pdf(filename);
+ create_pdf(filename);
}
catch (std::exception& e)
{
- std::cerr << e.what() << std::endl;
- exit(2);
+ std::cerr << e.what() << std::endl;
+ exit(2);
}
return 0;
diff --git a/examples/pdf-custom-filter.cc b/examples/pdf-custom-filter.cc
index a958a782..ad4189a3 100644
--- a/examples/pdf-custom-filter.cc
+++ b/examples/pdf-custom-filter.cc
@@ -207,7 +207,7 @@ class StreamReplacer: public QPDFObjectHandle::StreamDataProvider
StreamReplacer(QPDF* pdf);
virtual ~StreamReplacer() = default;
virtual void provideStreamData(int objid, int generation,
- Pipeline* pipeline) override;
+ Pipeline* pipeline) override;
void registerStream(
QPDFObjectHandle stream,
@@ -473,7 +473,7 @@ int main(int argc, char* argv[])
// For libtool's sake....
if (strncmp(whoami, "lt-", 3) == 0)
{
- whoami += 3;
+ whoami += 3;
}
char const* infilename = 0;
@@ -517,7 +517,7 @@ int main(int argc, char* argv[])
catch (std::exception &e)
{
std::cerr << whoami << ": exception: " << e.what() << std::endl;
- exit(2);
+ exit(2);
}
return 0;
diff --git a/examples/pdf-double-page-size.cc b/examples/pdf-double-page-size.cc
index 6c5e5913..c14b3dc5 100644
--- a/examples/pdf-double-page-size.cc
+++ b/examples/pdf-double-page-size.cc
@@ -13,9 +13,9 @@ static char const* whoami = 0;
void usage()
{
std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf [in-password]"
- << std::endl
- << "Double size of all pages in infile.pdf;"
- << " write output to outfile.pdf" << std::endl;
+ << std::endl
+ << "Double size of all pages in infile.pdf;"
+ << " write output to outfile.pdf" << std::endl;
exit(2);
}
@@ -26,18 +26,18 @@ static void doubleBoxSize(QPDFObjectHandle& page, char const* box_name)
QPDFObjectHandle box = page.getKey(box_name);
if (box.isNull())
{
- return;
+ return;
}
if (! (box.isArray() && (box.getArrayNItems() == 4)))
{
- throw std::runtime_error(std::string("box ") + box_name +
- " is not an array of four elements");
+ throw std::runtime_error(std::string("box ") + box_name +
+ " is not an array of four elements");
}
std::vector<QPDFObjectHandle> doubled;
for (int i = 0; i < 4; ++i)
{
- doubled.push_back(
- QPDFObjectHandle::newReal(
+ doubled.push_back(
+ QPDFObjectHandle::newReal(
box.getArrayItem(i).getNumericValue() * 2.0, 2));
}
page.replaceKey(box_name, QPDFObjectHandle::newArray(doubled));
@@ -50,7 +50,7 @@ int main(int argc, char* argv[])
// For libtool's sake....
if (strncmp(whoami, "lt-", 3) == 0)
{
- whoami += 3;
+ whoami += 3;
}
// For test suite
@@ -64,7 +64,7 @@ int main(int argc, char* argv[])
if (! ((argc == 3) || (argc == 4)))
{
- usage();
+ usage();
}
char const* infilename = argv[1];
@@ -76,48 +76,48 @@ int main(int argc, char* argv[])
try
{
- QPDF qpdf;
- qpdf.processFile(infilename, password);
+ QPDF qpdf;
+ qpdf.processFile(infilename, password);
- std::vector<QPDFPageObjectHelper> pages =
+ std::vector<QPDFPageObjectHelper> pages =
QPDFPageDocumentHelper(qpdf).getAllPages();
- for (std::vector<QPDFPageObjectHelper>::iterator iter =
+ for (std::vector<QPDFPageObjectHelper>::iterator iter =
pages.begin();
- iter != pages.end(); ++iter)
- {
+ iter != pages.end(); ++iter)
+ {
QPDFPageObjectHelper& ph(*iter);
- QPDFObjectHandle page = ph.getObjectHandle();
+ QPDFObjectHandle page = ph.getObjectHandle();
- // Prepend the buffer to the page's contents
- ph.addPageContents(
+ // Prepend the buffer to the page's contents
+ ph.addPageContents(
QPDFObjectHandle::newStream(&qpdf, content), true);
- // Double the size of each of the content boxes
- doubleBoxSize(page, "/MediaBox");
- doubleBoxSize(page, "/CropBox");
- doubleBoxSize(page, "/BleedBox");
- doubleBoxSize(page, "/TrimBox");
- doubleBoxSize(page, "/ArtBox");
- }
+ // Double the size of each of the content boxes
+ doubleBoxSize(page, "/MediaBox");
+ doubleBoxSize(page, "/CropBox");
+ doubleBoxSize(page, "/BleedBox");
+ doubleBoxSize(page, "/TrimBox");
+ doubleBoxSize(page, "/ArtBox");
+ }
- // Write out a new file
- QPDFWriter w(qpdf, outfilename);
- if (static_id)
- {
- // For the test suite, uncompress streams and use static
- // IDs.
- w.setStaticID(true); // for testing only
- w.setStreamDataMode(qpdf_s_uncompress);
- }
- w.write();
- std::cout << whoami << ": new file written to " << outfilename
- << std::endl;
+ // Write out a new file
+ QPDFWriter w(qpdf, outfilename);
+ if (static_id)
+ {
+ // For the test suite, uncompress streams and use static
+ // IDs.
+ w.setStaticID(true); // for testing only
+ w.setStreamDataMode(qpdf_s_uncompress);
+ }
+ w.write();
+ std::cout << whoami << ": new file written to " << outfilename
+ << std::endl;
}
catch (std::exception &e)
{
- std::cerr << whoami << " processing file " << infilename << ": "
- << e.what() << std::endl;
- exit(2);
+ std::cerr << whoami << " processing file " << infilename << ": "
+ << e.what() << std::endl;
+ exit(2);
}
return 0;
diff --git a/examples/pdf-filter-tokens.cc b/examples/pdf-filter-tokens.cc
index baf7b3dc..b71857e3 100644
--- a/examples/pdf-filter-tokens.cc
+++ b/examples/pdf-filter-tokens.cc
@@ -23,7 +23,7 @@ static char const* whoami = 0;
void usage()
{
std::cerr << "Usage: " << whoami << " infile outfile" << std::endl
- << "Applies token filters to infile and writes outfile"
+ << "Applies token filters to infile and writes outfile"
<< std::endl;
exit(2);
}
@@ -195,20 +195,20 @@ int main(int argc, char* argv[])
// For libtool's sake....
if (strncmp(whoami, "lt-", 3) == 0)
{
- whoami += 3;
+ whoami += 3;
}
if (argc != 3)
{
- usage();
+ usage();
}
char const* infilename = argv[1];
char const* outfilename = argv[2];
try
{
- QPDF pdf;
- pdf.processFile(infilename);
+ QPDF pdf;
+ pdf.processFile(infilename);
std::vector<QPDFPageObjectHelper> pages =
QPDFPageDocumentHelper(pdf).getAllPages();
for (std::vector<QPDFPageObjectHelper>::iterator iter = pages.begin();
@@ -233,8 +233,8 @@ int main(int argc, char* argv[])
}
catch (std::exception& e)
{
- std::cerr << whoami << ": " << e.what() << std::endl;
- exit(2);
+ std::cerr << whoami << ": " << e.what() << std::endl;
+ exit(2);
}
return 0;
diff --git a/examples/pdf-invert-images.cc b/examples/pdf-invert-images.cc
index a61d170f..178cde95 100644
--- a/examples/pdf-invert-images.cc
+++ b/examples/pdf-invert-images.cc
@@ -14,9 +14,9 @@ static char const* whoami = 0;
void usage()
{
std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf [in-password]"
- << std::endl
- << "Invert some images in infile.pdf;"
- << " write output to outfile.pdf" << std::endl;
+ << std::endl
+ << "Invert some images in infile.pdf;"
+ << " write output to outfile.pdf" << std::endl;
exit(2);
}
@@ -36,7 +36,7 @@ class ImageInverter: public QPDFObjectHandle::StreamDataProvider
{
}
virtual void provideStreamData(int objid, int generation,
- Pipeline* pipeline) override;
+ Pipeline* pipeline) override;
void registerImage(
QPDFObjectHandle image,
@@ -80,13 +80,13 @@ ImageInverter::registerImage(
// with it explicitly here. We could explicitly use /DCTDecode and
// write through a DCT filter if we wanted.
image.replaceStreamData(self,
- QPDFObjectHandle::newNull(),
- QPDFObjectHandle::newNull());
+ QPDFObjectHandle::newNull(),
+ QPDFObjectHandle::newNull());
}
void
ImageInverter::provideStreamData(int objid, int generation,
- Pipeline* pipeline)
+ Pipeline* pipeline)
{
// Use the object and generation number supplied to look up the
// image data. Then invert the image data and write the inverted
@@ -99,8 +99,8 @@ ImageInverter::provideStreamData(int objid, int generation,
unsigned char ch;
for (size_t i = 0; i < size; ++i)
{
- ch = QIntC::to_uchar(0xff - buf[i]);
- pipeline->write(&ch, 1);
+ ch = QIntC::to_uchar(0xff - buf[i]);
+ pipeline->write(&ch, 1);
}
pipeline->finish();
}
@@ -112,7 +112,7 @@ int main(int argc, char* argv[])
// For libtool's sake....
if (strncmp(whoami, "lt-", 3) == 0)
{
- whoami += 3;
+ whoami += 3;
}
// For test suite
@@ -126,7 +126,7 @@ int main(int argc, char* argv[])
if (! ((argc == 3) || (argc == 4)))
{
- usage();
+ usage();
}
char const* infilename = argv[1];
@@ -135,64 +135,64 @@ int main(int argc, char* argv[])
try
{
- QPDF qpdf;
- qpdf.processFile(infilename, password);
+ QPDF qpdf;
+ qpdf.processFile(infilename, password);
- ImageInverter* inv = new ImageInverter;
- auto p = PointerHolder<QPDFObjectHandle::StreamDataProvider>(inv);
+ ImageInverter* inv = new ImageInverter;
+ auto p = PointerHolder<QPDFObjectHandle::StreamDataProvider>(inv);
- // For each page...
- std::vector<QPDFPageObjectHelper> pages =
+ // 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);
- // Get all images on the page.
- std::map<std::string, QPDFObjectHandle> images =
- page.getImages();
- for (auto& iter2: images)
- {
- QPDFObjectHandle& image = iter2.second;
- QPDFObjectHandle image_dict = image.getDict();
- QPDFObjectHandle color_space =
- image_dict.getKey("/ColorSpace");
- QPDFObjectHandle bits_per_component =
- image_dict.getKey("/BitsPerComponent");
-
- // For our example, we can only work with images 8-bit
- // grayscale images that we can fully decode. Use
- // pipeStreamData with a null pipeline to determine
- // whether the image is filterable. Directly inspect
- // keys to determine the image type.
- if (image.pipeStreamData(0, qpdf_ef_compress,
+ for (std::vector<QPDFPageObjectHelper>::iterator iter = pages.begin();
+ iter != pages.end(); ++iter)
+ {
+ QPDFPageObjectHelper& page(*iter);
+ // Get all images on the page.
+ std::map<std::string, QPDFObjectHandle> images =
+ page.getImages();
+ for (auto& iter2: images)
+ {
+ QPDFObjectHandle& image = iter2.second;
+ QPDFObjectHandle image_dict = image.getDict();
+ QPDFObjectHandle color_space =
+ image_dict.getKey("/ColorSpace");
+ QPDFObjectHandle bits_per_component =
+ image_dict.getKey("/BitsPerComponent");
+
+ // For our example, we can only work with images 8-bit
+ // grayscale images that we can fully decode. Use
+ // pipeStreamData with a null pipeline to determine
+ // whether the image is filterable. Directly inspect
+ // keys to determine the image type.
+ if (image.pipeStreamData(0, qpdf_ef_compress,
qpdf_dl_all) &&
color_space.isNameAndEquals("/DeviceGray") &&
- bits_per_component.isInteger() &&
- (bits_per_component.getIntValue() == 8))
- {
+ bits_per_component.isInteger() &&
+ (bits_per_component.getIntValue() == 8))
+ {
inv->registerImage(image, p);
}
- }
- }
-
- // Write out a new file
- QPDFWriter w(qpdf, outfilename);
- if (static_id)
- {
- // For the test suite, uncompress streams and use static
- // IDs.
- w.setStaticID(true); // for testing only
- }
- w.write();
- std::cout << whoami << ": new file written to " << outfilename
- << std::endl;
+ }
+ }
+
+ // Write out a new file
+ QPDFWriter w(qpdf, outfilename);
+ if (static_id)
+ {
+ // For the test suite, uncompress streams and use static
+ // IDs.
+ w.setStaticID(true); // for testing only
+ }
+ w.write();
+ std::cout << whoami << ": new file written to " << outfilename
+ << std::endl;
}
catch (std::exception &e)
{
- std::cerr << whoami << " processing file " << infilename << ": "
- << e.what() << std::endl;
- exit(2);
+ std::cerr << whoami << " processing file " << infilename << ": "
+ << e.what() << std::endl;
+ exit(2);
}
return 0;
diff --git a/examples/pdf-linearize.c b/examples/pdf-linearize.c
index adeaffb4..2b099066 100644
--- a/examples/pdf-linearize.c
+++ b/examples/pdf-linearize.c
@@ -32,20 +32,20 @@ int main(int argc, char* argv[])
if ((p = strrchr(argv[0], '/')) != NULL)
{
- whoami = p + 1;
+ whoami = p + 1;
}
else if ((p = strrchr(argv[0], '\\')) != NULL)
{
- whoami = p + 1;
+ whoami = p + 1;
}
else
{
- whoami = argv[0];
+ whoami = argv[0];
}
if (argc != 4)
{
- usage();
+ usage();
}
infile = argv[1];
@@ -53,36 +53,36 @@ int main(int argc, char* argv[])
outfile = argv[3];
if (((qpdf_read(qpdf, infile, password) & QPDF_ERRORS) == 0) &&
- ((qpdf_init_write(qpdf, outfile) & QPDF_ERRORS) == 0))
+ ((qpdf_init_write(qpdf, outfile) & QPDF_ERRORS) == 0))
{
/* Use static ID for testing only. For production, a
* non-static ID is used. See also
* qpdf_set_deterministic_ID. */
- qpdf_set_static_ID(qpdf, QPDF_TRUE); /* for testing only */
- qpdf_set_linearization(qpdf, QPDF_TRUE);
+ qpdf_set_static_ID(qpdf, QPDF_TRUE); /* for testing only */
+ qpdf_set_linearization(qpdf, QPDF_TRUE);
qpdf_register_progress_reporter(qpdf, write_progress, infile);
- qpdf_write(qpdf);
+ qpdf_write(qpdf);
}
while (qpdf_more_warnings(qpdf))
{
- warnings = 1;
- printf("warning: %s\n",
- qpdf_get_error_full_text(qpdf, qpdf_next_warning(qpdf)));
+ warnings = 1;
+ printf("warning: %s\n",
+ qpdf_get_error_full_text(qpdf, qpdf_next_warning(qpdf)));
}
if (qpdf_has_error(qpdf))
{
- errors = 1;
- printf("error: %s\n",
- qpdf_get_error_full_text(qpdf, qpdf_get_error(qpdf)));
+ errors = 1;
+ printf("error: %s\n",
+ qpdf_get_error_full_text(qpdf, qpdf_get_error(qpdf)));
}
qpdf_cleanup(&qpdf);
if (errors)
{
- return 2;
+ return 2;
}
else if (warnings)
{
- return 3;
+ return 3;
}
return 0;
diff --git a/examples/pdf-mod-info.cc b/examples/pdf-mod-info.cc
index 20f13a7a..6067fcfe 100644
--- a/examples/pdf-mod-info.cc
+++ b/examples/pdf-mod-info.cc
@@ -16,39 +16,39 @@ static char const* whoami = 0;
void usage()
{
std::cerr
- << "Usage: " << whoami
- << " --in in_file [--out out_file] [--key key [--val val]?]+\n"
- << "Modifies/Adds/Removes PDF /Info entries in the in_file\n"
- << "and stores the result in out_file\n"
- << "Special mode: " << whoami << " --dump file\n"
- << "dumps all /Info entries to stdout\n";
+ << "Usage: " << whoami
+ << " --in in_file [--out out_file] [--key key [--val val]?]+\n"
+ << "Modifies/Adds/Removes PDF /Info entries in the in_file\n"
+ << "and stores the result in out_file\n"
+ << "Special mode: " << whoami << " --dump file\n"
+ << "dumps all /Info entries to stdout\n";
exit(2);
}
void dumpInfoDict(QPDF& pdf,
- std::ostream& os = std::cout,
- std::string const& sep = ":\t")
+ std::ostream& os = std::cout,
+ std::string const& sep = ":\t")
{
QPDFObjectHandle trailer = pdf.getTrailer();
if (trailer.hasKey("/Info"))
{
- for (auto& it: trailer.getKey("/Info").ditems())
- {
- std::string val;
- if (it.second.isString())
- {
- val = it.second.getStringValue();
- }
- else if (it.second.isName())
- {
- val = it.second.getName();
- }
- else // according to PDF Spec 1.5, shouldn't happen
- {
- val = it.second.unparseResolved();
- }
- os << it.first.substr(1) << sep << val << std::endl; // skip '/'
- }
+ for (auto& it: trailer.getKey("/Info").ditems())
+ {
+ std::string val;
+ if (it.second.isString())
+ {
+ val = it.second.getStringValue();
+ }
+ else if (it.second.isName())
+ {
+ val = it.second.getName();
+ }
+ else // according to PDF Spec 1.5, shouldn't happen
+ {
+ val = it.second.unparseResolved();
+ }
+ os << it.first.substr(1) << sep << val << std::endl; // skip '/'
+ }
}
}
@@ -56,14 +56,14 @@ void pdfDumpInfoDict(char const* fname)
{
try
{
- QPDF pdf;
- pdf.processFile(fname);
- dumpInfoDict(pdf);
+ QPDF pdf;
+ pdf.processFile(fname);
+ dumpInfoDict(pdf);
}
catch (std::exception& e)
{
- std::cerr << e.what() << std::endl;
- exit(2);
+ std::cerr << e.what() << std::endl;
+ exit(2);
}
}
@@ -78,19 +78,19 @@ int main(int argc, char* argv[])
// For libtool's sake....
if (strncmp(whoami, "lt-", 3) == 0)
{
- whoami += 3;
+ whoami += 3;
}
if ((argc == 2) && (! strcmp(argv[1], "--version")) )
{
- std::cout << whoami << " version " << version << std::endl;
- exit(0);
+ std::cout << whoami << " version " << version << std::endl;
+ exit(0);
}
if ((argc == 3) && (! strcmp(argv[1], "--dump")))
{
- QTC::TC("examples", "pdf-mod-info --dump");
- pdfDumpInfoDict(argv[2]);
- exit(0);
+ QTC::TC("examples", "pdf-mod-info --dump");
+ pdfDumpInfoDict(argv[2]);
+ exit(0);
}
char* fl_in = 0;
@@ -99,59 +99,59 @@ int main(int argc, char* argv[])
for (int i = 1; i < argc; ++i)
{
- if ((! strcmp(argv[i], "--in")) && (++i < argc))
- {
- fl_in = argv[i];
- }
- else if ((! strcmp(argv[i], "--out")) && (++i < argc))
- {
- fl_out = argv[i];
- }
- else if (! strcmp(argv[i], "--static-id")) // don't document
- {
- static_id = true; // this should be used in test suites only
- }
- else if ((! strcmp(argv[i], "--key")) && (++i < argc))
- {
- QTC::TC("examples", "pdf-mod-info -key");
- cur_key = argv[i];
- if (! ((cur_key.length() > 0) && (cur_key.at(0) == '/')))
- {
- cur_key = "/" + cur_key;
- }
- Keys[cur_key] = "";
- }
- else if ((! strcmp(argv[i], "--val")) && (++i < argc))
- {
- if (cur_key.empty())
- {
- QTC::TC("examples", "pdf-mod-info usage wrong val");
- usage();
- }
- QTC::TC("examples", "pdf-mod-info -val");
- Keys[cur_key] = argv[i];
- cur_key.clear();
- }
- else
- {
- QTC::TC("examples", "pdf-mod-info usage junk");
- usage();
- }
+ if ((! strcmp(argv[i], "--in")) && (++i < argc))
+ {
+ fl_in = argv[i];
+ }
+ else if ((! strcmp(argv[i], "--out")) && (++i < argc))
+ {
+ fl_out = argv[i];
+ }
+ else if (! strcmp(argv[i], "--static-id")) // don't document
+ {
+ static_id = true; // this should be used in test suites only
+ }
+ else if ((! strcmp(argv[i], "--key")) && (++i < argc))
+ {
+ QTC::TC("examples", "pdf-mod-info -key");
+ cur_key = argv[i];
+ if (! ((cur_key.length() > 0) && (cur_key.at(0) == '/')))
+ {
+ cur_key = "/" + cur_key;
+ }
+ Keys[cur_key] = "";
+ }
+ else if ((! strcmp(argv[i], "--val")) && (++i < argc))
+ {
+ if (cur_key.empty())
+ {
+ QTC::TC("examples", "pdf-mod-info usage wrong val");
+ usage();
+ }
+ QTC::TC("examples", "pdf-mod-info -val");
+ Keys[cur_key] = argv[i];
+ cur_key.clear();
+ }
+ else
+ {
+ QTC::TC("examples", "pdf-mod-info usage junk");
+ usage();
+ }
}
if (! fl_in)
{
- QTC::TC("examples", "pdf-mod-info no in file");
- usage();
+ QTC::TC("examples", "pdf-mod-info no in file");
+ usage();
}
if (! fl_out)
{
- QTC::TC("examples", "pdf-mod-info in-place");
- fl_out = fl_in;
+ QTC::TC("examples", "pdf-mod-info in-place");
+ fl_out = fl_in;
}
if (Keys.size() == 0)
{
- QTC::TC("examples", "pdf-mod-info no keys");
- usage();
+ QTC::TC("examples", "pdf-mod-info no keys");
+ usage();
}
std::string fl_tmp = fl_out;
@@ -159,62 +159,62 @@ int main(int argc, char* argv[])
try
{
- QPDF file;
- file.processFile(fl_in);
-
- QPDFObjectHandle filetrailer = file.getTrailer();
- QPDFObjectHandle fileinfo;
-
- for (std::map<std::string, std::string>::const_iterator it =
- Keys.begin(); Keys.end() != it; ++it)
- {
- if (! fileinfo.isInitialized())
- {
- if (filetrailer.hasKey("/Info"))
- {
- QTC::TC("examples", "pdf-mod-info has info");
- fileinfo = filetrailer.getKey("/Info");
- }
- else
- {
- QTC::TC("examples", "pdf-mod-info file no info");
- fileinfo = QPDFObjectHandle::newDictionary();
- filetrailer.replaceKey("/Info", fileinfo);
- }
- }
- if (it->second == "")
- {
- fileinfo.removeKey(it->first);
- }
- else
- {
- QPDFObjectHandle elt = fileinfo.newString(it->second);
- elt.makeDirect();
- fileinfo.replaceKey(it->first, elt);
- }
- }
- QPDFWriter w(file, fl_tmp.c_str());
- w.setStreamDataMode(qpdf_s_preserve);
- w.setLinearization(true);
- w.setStaticID(static_id); // for testing only
- w.write();
+ QPDF file;
+ file.processFile(fl_in);
+
+ QPDFObjectHandle filetrailer = file.getTrailer();
+ QPDFObjectHandle fileinfo;
+
+ for (std::map<std::string, std::string>::const_iterator it =
+ Keys.begin(); Keys.end() != it; ++it)
+ {
+ if (! fileinfo.isInitialized())
+ {
+ if (filetrailer.hasKey("/Info"))
+ {
+ QTC::TC("examples", "pdf-mod-info has info");
+ fileinfo = filetrailer.getKey("/Info");
+ }
+ else
+ {
+ QTC::TC("examples", "pdf-mod-info file no info");
+ fileinfo = QPDFObjectHandle::newDictionary();
+ filetrailer.replaceKey("/Info", fileinfo);
+ }
+ }
+ if (it->second == "")
+ {
+ fileinfo.removeKey(it->first);
+ }
+ else
+ {
+ QPDFObjectHandle elt = fileinfo.newString(it->second);
+ elt.makeDirect();
+ fileinfo.replaceKey(it->first, elt);
+ }
+ }
+ QPDFWriter w(file, fl_tmp.c_str());
+ w.setStreamDataMode(qpdf_s_preserve);
+ w.setLinearization(true);
+ w.setStaticID(static_id); // for testing only
+ w.write();
}
catch (std::exception& e)
{
- std::cerr << e.what() << std::endl;
- exit(2);
+ std::cerr << e.what() << std::endl;
+ exit(2);
}
try
{
- (void) remove(fl_out);
- QUtil::os_wrapper("rename " + fl_tmp + " " + std::string(fl_out),
- rename(fl_tmp.c_str(), fl_out));
+ (void) remove(fl_out);
+ QUtil::os_wrapper("rename " + fl_tmp + " " + std::string(fl_out),
+ rename(fl_tmp.c_str(), fl_out));
}
catch (std::exception& e)
{
- std::cerr << e.what() << std::endl;
- exit(2);
+ std::cerr << e.what() << std::endl;
+ exit(2);
}
return 0;
diff --git a/examples/pdf-name-number-tree.cc b/examples/pdf-name-number-tree.cc
index cfae4a6b..2f16b5f0 100644
--- a/examples/pdf-name-number-tree.cc
+++ b/examples/pdf-name-number-tree.cc
@@ -11,9 +11,9 @@ static char const* whoami = 0;
void usage()
{
std::cerr << "Usage: " << whoami << " outfile.pdf"
- << std::endl
- << "Create some name/number trees and write to a file"
- << std::endl;
+ << std::endl
+ << "Create some name/number trees and write to a file"
+ << std::endl;
exit(2);
}
@@ -24,12 +24,12 @@ int main(int argc, char* argv[])
// For libtool's sake....
if (strncmp(whoami, "lt-", 3) == 0)
{
- whoami += 3;
+ whoami += 3;
}
if (argc != 2)
{
- usage();
+ usage();
}
char const* outfilename = argv[1];
diff --git a/examples/pdf-npages.cc b/examples/pdf-npages.cc
index c62d33de..d39c6434 100644
--- a/examples/pdf-npages.cc
+++ b/examples/pdf-npages.cc
@@ -10,7 +10,7 @@ static char const* whoami = 0;
void usage()
{
std::cerr << "Usage: " << whoami << " filename" << std::endl
- << "Prints the number of pages in filename" << std::endl;
+ << "Prints the number of pages in filename" << std::endl;
exit(2);
}
@@ -21,34 +21,34 @@ int main(int argc, char* argv[])
// For libtool's sake....
if (strncmp(whoami, "lt-", 3) == 0)
{
- whoami += 3;
+ whoami += 3;
}
if ((argc == 2) && (strcmp(argv[1], "--version") == 0))
{
- std::cout << whoami << " version 1.3" << std::endl;
- exit(0);
+ std::cout << whoami << " version 1.3" << std::endl;
+ exit(0);
}
if (argc != 2)
{
- usage();
+ usage();
}
char const* filename = argv[1];
try
{
- QPDF pdf;
- pdf.processFile(filename);
- QPDFObjectHandle root = pdf.getRoot();
- QPDFObjectHandle pages = root.getKey("/Pages");
- QPDFObjectHandle count = pages.getKey("/Count");
- std::cout << count.getIntValue() << std::endl;
+ QPDF pdf;
+ pdf.processFile(filename);
+ QPDFObjectHandle root = pdf.getRoot();
+ QPDFObjectHandle pages = root.getKey("/Pages");
+ QPDFObjectHandle count = pages.getKey("/Count");
+ std::cout << count.getIntValue() << std::endl;
}
catch (std::exception& e)
{
- std::cerr << whoami << ": " << e.what() << std::endl;
- exit(2);
+ std::cerr << whoami << ": " << e.what() << std::endl;
+ exit(2);
}
return 0;
diff --git a/examples/pdf-overlay-page.cc b/examples/pdf-overlay-page.cc
index 7b8888e4..def047c5 100644
--- a/examples/pdf-overlay-page.cc
+++ b/examples/pdf-overlay-page.cc
@@ -17,10 +17,10 @@ static char const* whoami = 0;
void usage()
{
std::cerr << "Usage: " << whoami << " infile pagefile outfile"
- << std::endl
- << "Stamp page 1 of pagefile on every page of infile,"
+ << std::endl
+ << "Stamp page 1 of pagefile on every page of infile,"
<< " writing to outfile"
- << std::endl;
+ << std::endl;
exit(2);
}
@@ -91,7 +91,7 @@ int main(int argc, char* argv[])
// For libtool's sake....
if (strncmp(whoami, "lt-", 3) == 0)
{
- whoami += 3;
+ whoami += 3;
}
if (argc != 4)
@@ -108,8 +108,8 @@ int main(int argc, char* argv[])
}
catch (std::exception &e)
{
- std::cerr << whoami << ": " << e.what() << std::endl;
- exit(2);
+ std::cerr << whoami << ": " << e.what() << std::endl;
+ exit(2);
}
return 0;
}
diff --git a/examples/pdf-parse-content.cc b/examples/pdf-parse-content.cc
index f1680f72..89460e18 100644
--- a/examples/pdf-parse-content.cc
+++ b/examples/pdf-parse-content.cc
@@ -13,7 +13,7 @@ static char const* whoami = 0;
void usage()
{
std::cerr << "Usage: " << whoami << " filename page-number" << std::endl
- << "Prints a dump of the objects in the content streams"
+ << "Prints a dump of the objects in the content streams"
<< " of the given page." << std::endl
<< "Pages are numbered from 1." << std::endl;
exit(2);
@@ -66,20 +66,20 @@ int main(int argc, char* argv[])
// For libtool's sake....
if (strncmp(whoami, "lt-", 3) == 0)
{
- whoami += 3;
+ whoami += 3;
}
if (argc != 3)
{
- usage();
+ usage();
}
char const* filename = argv[1];
int pageno = QUtil::string_to_int(argv[2]);
try
{
- QPDF pdf;
- pdf.processFile(filename);
+ QPDF pdf;
+ pdf.processFile(filename);
std::vector<QPDFPageObjectHelper> pages =
QPDFPageDocumentHelper(pdf).getAllPages();
if ((pageno < 1) || (QIntC::to_size(pageno) > pages.size()))
@@ -93,8 +93,8 @@ int main(int argc, char* argv[])
}
catch (std::exception& e)
{
- std::cerr << whoami << ": " << e.what() << std::endl;
- exit(2);
+ std::cerr << whoami << ": " << e.what() << std::endl;
+ exit(2);
}
return 0;
diff --git a/examples/pdf-set-form-values.cc b/examples/pdf-set-form-values.cc
index becbedf3..ddd3b2dd 100644
--- a/examples/pdf-set-form-values.cc
+++ b/examples/pdf-set-form-values.cc
@@ -13,8 +13,8 @@ static char const* whoami = 0;
void usage()
{
std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf value"
- << std::endl
- << "Set the value of all text fields to a specified value"
+ << std::endl
+ << "Set the value of all text fields to a specified value"
<< std::endl;
exit(2);
}
@@ -27,7 +27,7 @@ int main(int argc, char* argv[])
// For libtool's sake....
if (strncmp(whoami, "lt-", 3) == 0)
{
- whoami += 3;
+ whoami += 3;
}
if (argc != 4)
@@ -47,8 +47,8 @@ int main(int argc, char* argv[])
try
{
- QPDF qpdf;
- qpdf.processFile(infilename);
+ QPDF qpdf;
+ qpdf.processFile(infilename);
// We will iterate through form fields by starting at the page
// level and looking at each field for each page. We could
@@ -94,16 +94,16 @@ int main(int argc, char* argv[])
}
}
- // Write out a new file
- QPDFWriter w(qpdf, outfilename);
+ // Write out a new file
+ QPDFWriter w(qpdf, outfilename);
w.setStaticID(true); // for testing only
- w.write();
+ w.write();
}
catch (std::exception &e)
{
- std::cerr << whoami << " processing file " << infilename << ": "
- << e.what() << std::endl;
- exit(2);
+ std::cerr << whoami << " processing file " << infilename << ": "
+ << e.what() << std::endl;
+ exit(2);
}
return 0;
diff --git a/examples/pdf-split-pages.cc b/examples/pdf-split-pages.cc
index ea1c92bc..381480ef 100644
--- a/examples/pdf-split-pages.cc
+++ b/examples/pdf-split-pages.cc
@@ -38,13 +38,13 @@ static void process(char const* whoami,
outpdf.emptyPDF();
QPDFPageDocumentHelper(outpdf).addPage(page, false);
QPDFWriter outpdfw(outpdf, outfile.c_str());
- if (static_id)
- {
- // For the test suite, uncompress streams and use static
- // IDs.
- outpdfw.setStaticID(true); // for testing only
- outpdfw.setStreamDataMode(qpdf_s_uncompress);
- }
+ if (static_id)
+ {
+ // For the test suite, uncompress streams and use static
+ // IDs.
+ outpdfw.setStaticID(true); // for testing only
+ outpdfw.setStreamDataMode(qpdf_s_uncompress);
+ }
outpdfw.write();
}
}
@@ -62,7 +62,7 @@ int main(int argc, char* argv[])
// For libtool's sake....
if (strncmp(whoami, "lt-", 3) == 0)
{
- whoami += 3;
+ whoami += 3;
}
// For test suite
if ((argc > 1) && (strcmp(argv[1], " --static-id") == 0))
diff --git a/examples/qpdf-job.cc b/examples/qpdf-job.cc
index 29f23a34..f3905e0d 100644
--- a/examples/qpdf-job.cc
+++ b/examples/qpdf-job.cc
@@ -30,7 +30,7 @@ int main(int argc, char* argv[])
// For libtool's sake....
if (strncmp(whoami, "lt-", 3) == 0)
{
- whoami += 3;
+ whoami += 3;
}
if (argc != 1)
diff --git a/examples/qpdfjob-c.c b/examples/qpdfjob-c.c
index ac58b8ae..ad81655a 100644
--- a/examples/qpdfjob-c.c
+++ b/examples/qpdfjob-c.c
@@ -26,20 +26,20 @@ int main(int argc, char* argv[])
if ((p = strrchr(argv[0], '/')) != NULL)
{
- whoami = p + 1;
+ whoami = p + 1;
}
else if ((p = strrchr(argv[0], '\\')) != NULL)
{
- whoami = p + 1;
+ whoami = p + 1;
}
else
{
- whoami = argv[0];
+ whoami = argv[0];
}
if (argc != 3)
{
- usage();
+ usage();
}
infile = argv[1];
diff --git a/examples/qtest/bookmarks.test b/examples/qtest/bookmarks.test
index cff8fc60..e5e3172b 100644
--- a/examples/qtest/bookmarks.test
+++ b/examples/qtest/bookmarks.test
@@ -15,38 +15,38 @@ foreach my $show ("", " --show-open")
{
my $xshow = $show ? $show : "x";
my $xstyle = $style ? $style : "x";
- my $out = "test.$xshow.$xstyle.out";
- $out =~ s/ //g;
- $td->runtest("show:$show, style:$style",
- {$td->COMMAND => "pdf-bookmarks $show $style 1.pdf"},
- {$td->FILE => $out, $td->EXIT_STATUS => 0},
- $td->NORMALIZE_NEWLINES);
+ my $out = "test.$xshow.$xstyle.out";
+ $out =~ s/ //g;
+ $td->runtest("show:$show, style:$style",
+ {$td->COMMAND => "pdf-bookmarks $show $style 1.pdf"},
+ {$td->FILE => $out, $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
}
}
$td->runtest("no bookmarks",
- {$td->COMMAND => "pdf-bookmarks 2.pdf"},
- {$td->STRING => "2.pdf has no bookmarks\n",
- $td->EXIT_STATUS => 0},
- $td->NORMALIZE_NEWLINES);
+ {$td->COMMAND => "pdf-bookmarks 2.pdf"},
+ {$td->STRING => "2.pdf has no bookmarks\n",
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->runtest("bad",
- {$td->COMMAND => "pdf-bookmarks 3.pdf"},
- {$td->REGEXP => "pdf-bookmarks processing file 3.pdf: " .
- ".*unable to find trailer.*",
- $td->EXIT_STATUS => 2},
- $td->NORMALIZE_NEWLINES);
+ {$td->COMMAND => "pdf-bookmarks 3.pdf"},
+ {$td->REGEXP => "pdf-bookmarks processing file 3.pdf: " .
+ ".*unable to find trailer.*",
+ $td->EXIT_STATUS => 2},
+ $td->NORMALIZE_NEWLINES);
$td->runtest("encrypted, targets",
- {$td->COMMAND => "pdf-bookmarks --show-targets 4.pdf user"},
- {$td->FILE => "encrypted.out",
- $td->EXIT_STATUS => 0},
- $td->NORMALIZE_NEWLINES);
+ {$td->COMMAND => "pdf-bookmarks --show-targets 4.pdf user"},
+ {$td->FILE => "encrypted.out",
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->runtest("bookmarks deleted",
- {$td->COMMAND => "pdf-bookmarks 5.pdf user"},
- {$td->STRING => "5.pdf has no bookmarks\n",
- $td->EXIT_STATUS => 0},
- $td->NORMALIZE_NEWLINES);
+ {$td->COMMAND => "pdf-bookmarks 5.pdf user"},
+ {$td->STRING => "5.pdf has no bookmarks\n",
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->runtest("non-trivial pdf doc to unicode",
{$td->COMMAND => "pdf-bookmarks issue-179.pdf"},
diff --git a/examples/qtest/count-strings.test b/examples/qtest/count-strings.test
index ba3f835b..c56d1b62 100644
--- a/examples/qtest/count-strings.test
+++ b/examples/qtest/count-strings.test
@@ -10,8 +10,8 @@ require TestDriver;
my $td = new TestDriver('pdf-count-strings');
$td->runtest("filter tokens",
- {$td->COMMAND => "pdf-count-strings in.pdf"},
- {$td->FILE => "out", $td->EXIT_STATUS => 0},
+ {$td->COMMAND => "pdf-count-strings in.pdf"},
+ {$td->FILE => "out", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
$td->report(1);
diff --git a/examples/qtest/create.test b/examples/qtest/create.test
index f18c5fd6..6bf075f4 100644
--- a/examples/qtest/create.test
+++ b/examples/qtest/create.test
@@ -12,8 +12,8 @@ cleanup();
my $td = new TestDriver('create');
$td->runtest("create a simple PDF",
- {$td->COMMAND => "pdf-create a.pdf"},
- {$td->FILE => "create.out", $td->EXIT_STATUS => 0},
+ {$td->COMMAND => "pdf-create a.pdf"},
+ {$td->FILE => "create.out", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
cleanup();
diff --git a/examples/qtest/double-page-size.test b/examples/qtest/double-page-size.test
index 780a8f0d..a7d6968e 100644
--- a/examples/qtest/double-page-size.test
+++ b/examples/qtest/double-page-size.test
@@ -12,16 +12,16 @@ my $td = new TestDriver('double-page-size');
cleanup();
$td->runtest("double page size",
- {$td->COMMAND => ['pdf-double-page-size', ' --static-id',
+ {$td->COMMAND => ['pdf-double-page-size', ' --static-id',
'in.pdf', 'a.pdf']},
- {$td->STRING =>
- "pdf-double-page-size: new file written to a.pdf\n",
- $td->EXIT_STATUS => 0},
- $td->NORMALIZE_NEWLINES);
+ {$td->STRING =>
+ "pdf-double-page-size: new file written to a.pdf\n",
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->runtest("check output",
- {$td->FILE => "a.pdf"},
- {$td->FILE => "out.pdf"});
+ {$td->FILE => "a.pdf"},
+ {$td->FILE => "out.pdf"});
cleanup();
diff --git a/examples/qtest/filter-tokens.test b/examples/qtest/filter-tokens.test
index e7e458ac..3275dbc4 100644
--- a/examples/qtest/filter-tokens.test
+++ b/examples/qtest/filter-tokens.test
@@ -12,12 +12,12 @@ my $td = new TestDriver('pdf-filter-tokens');
cleanup();
$td->runtest("filter tokens",
- {$td->COMMAND => "pdf-filter-tokens in.pdf a.pdf"},
- {$td->STRING => "", $td->EXIT_STATUS => 0});
+ {$td->COMMAND => "pdf-filter-tokens in.pdf a.pdf"},
+ {$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("check output",
- {$td->FILE => "a.pdf"},
- {$td->FILE => "out.pdf"});
+ {$td->FILE => "a.pdf"},
+ {$td->FILE => "out.pdf"});
cleanup();
diff --git a/examples/qtest/invert-images.test b/examples/qtest/invert-images.test
index 33ffca47..d1e3c939 100644
--- a/examples/qtest/invert-images.test
+++ b/examples/qtest/invert-images.test
@@ -12,16 +12,16 @@ my $td = new TestDriver('invert-images');
cleanup();
$td->runtest("invert images",
- {$td->COMMAND => ['pdf-invert-images', ' --static-id',
+ {$td->COMMAND => ['pdf-invert-images', ' --static-id',
'in.pdf', 'a.pdf']},
- {$td->STRING =>
- "pdf-invert-images: new file written to a.pdf\n",
- $td->EXIT_STATUS => 0},
- $td->NORMALIZE_NEWLINES);
+ {$td->STRING =>
+ "pdf-invert-images: new file written to a.pdf\n",
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->runtest("check output",
- {$td->FILE => "a.pdf"},
- {$td->FILE => "out.pdf"});
+ {$td->FILE => "a.pdf"},
+ {$td->FILE => "out.pdf"});
cleanup();
diff --git a/examples/qtest/linearize.test b/examples/qtest/linearize.test
index 94fbcd05..711e697b 100644
--- a/examples/qtest/linearize.test
+++ b/examples/qtest/linearize.test
@@ -14,14 +14,14 @@ my $td = new TestDriver('linearize');
my $qpdf = $ENV{'QPDF_BIN'} or die;
$td->runtest("linearize",
- {$td->COMMAND => "pdf-linearize input.pdf '' a.pdf"},
- {$td->REGEXP => '(?s).*input\.pdf progress: \d+\%.*',
+ {$td->COMMAND => "pdf-linearize input.pdf '' a.pdf"},
+ {$td->REGEXP => '(?s).*input\.pdf progress: \d+\%.*',
$td->EXIT_STATUS => 0});
$td->runtest("check",
- {$td->COMMAND => "$qpdf --check a.pdf"},
- {$td->FILE => "check.out", $td->EXIT_STATUS => 0},
- $td->NORMALIZE_NEWLINES);
+ {$td->COMMAND => "$qpdf --check a.pdf"},
+ {$td->FILE => "check.out", $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
cleanup();
diff --git a/examples/qtest/mod-info.test b/examples/qtest/mod-info.test
index 5f927170..ec09df9e 100644
--- a/examples/qtest/mod-info.test
+++ b/examples/qtest/mod-info.test
@@ -16,65 +16,65 @@ my $qpdf = $ENV{'QPDF_BIN'} or die;
cleanup();
$td->runtest("usage #1",
- {$td->COMMAND => "$prg --in target.pdf"},
- {$td->FILE => "usage.out",
- $td->EXIT_STATUS => 2},
- $td->NORMALIZE_NEWLINES);
+ {$td->COMMAND => "$prg --in target.pdf"},
+ {$td->FILE => "usage.out",
+ $td->EXIT_STATUS => 2},
+ $td->NORMALIZE_NEWLINES);
$td->runtest("usage #2",
- {$td->COMMAND => "$prg --key abc --val def"},
- {$td->FILE => "usage.out",
- $td->EXIT_STATUS => 2},
- $td->NORMALIZE_NEWLINES);
+ {$td->COMMAND => "$prg --key abc --val def"},
+ {$td->FILE => "usage.out",
+ $td->EXIT_STATUS => 2},
+ $td->NORMALIZE_NEWLINES);
$td->runtest("usage #3",
- {$td->COMMAND => "$prg --key abc --val def abc"},
- {$td->FILE => "usage.out",
- $td->EXIT_STATUS => 2},
- $td->NORMALIZE_NEWLINES);
+ {$td->COMMAND => "$prg --key abc --val def abc"},
+ {$td->FILE => "usage.out",
+ $td->EXIT_STATUS => 2},
+ $td->NORMALIZE_NEWLINES);
$td->runtest("usage #4",
- {$td->COMMAND => "$prg --in source1.pdf --key date --val 01/01/01 --val 12/12/12"},
- {$td->FILE => "usage.out",
- $td->EXIT_STATUS => 2},
- $td->NORMALIZE_NEWLINES);
+ {$td->COMMAND => "$prg --in source1.pdf --key date --val 01/01/01 --val 12/12/12"},
+ {$td->FILE => "usage.out",
+ $td->EXIT_STATUS => 2},
+ $td->NORMALIZE_NEWLINES);
$td->runtest("dump #1",
- {$td->COMMAND => "$prg --dump files/source1.pdf"},
- {$td->FILE => "dump.out",
- $td->EXIT_STATUS => 0},
- $td->NORMALIZE_NEWLINES);
+ {$td->COMMAND => "$prg --dump files/source1.pdf"},
+ {$td->FILE => "dump.out",
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->runtest("dump #2",
- {$td->COMMAND => "$prg --dump files/no-info.pdf"},
- {$td->STRING => "",
- $td->EXIT_STATUS => 0},
- $td->NORMALIZE_NEWLINES);
+ {$td->COMMAND => "$prg --dump files/no-info.pdf"},
+ {$td->STRING => "",
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->runtest("dump #3",
- {$td->COMMAND => "$prg --dump files/empty-info.pdf"},
- {$td->STRING => "",
- $td->EXIT_STATUS => 0});
+ {$td->COMMAND => "$prg --dump files/empty-info.pdf"},
+ {$td->STRING => "",
+ $td->EXIT_STATUS => 0});
run_and_cmp("modify Subject",
- "$prg --in files/source1.pdf --out out.pdf --key Subject " .
- "--val \"Export Business\"",
- "", "out.pdf", "files/1.qdf");
+ "$prg --in files/source1.pdf --out out.pdf --key Subject " .
+ "--val \"Export Business\"",
+ "", "out.pdf", "files/1.qdf");
run_and_cmp("add Subject, remove Producer, modify CreationDate",
- "$prg --in files/source2.pdf --out out.pdf --key Subject " .
- "--val \"Tammlin\" --key Producer --key CreationDate --val 12/12",
- "", "out.pdf", "files/2.qdf");
+ "$prg --in files/source2.pdf --out out.pdf --key Subject " .
+ "--val \"Tammlin\" --key Producer --key CreationDate --val 12/12",
+ "", "out.pdf", "files/2.qdf");
run_and_cmp("add Subject (empty-info file)",
- "$prg --in files/empty-info.pdf --out out.pdf --key Subject " .
- "--val Tammlin",
- "", "out.pdf", "files/3.qdf");
+ "$prg --in files/empty-info.pdf --out out.pdf --key Subject " .
+ "--val Tammlin",
+ "", "out.pdf", "files/3.qdf");
copy("files/no-info.pdf", "no-info.pdf") or die "can't copy no-info: $!";
run_and_cmp("in-place Producer added (no-info file)",
- "$prg --in no-info.pdf --key Producer --val \"Obivan Kinobi\"",
- "", "no-info.pdf", "files/4.qdf");
+ "$prg --in no-info.pdf --key Producer --val \"Obivan Kinobi\"",
+ "", "no-info.pdf", "files/4.qdf");
cleanup();
@@ -89,12 +89,12 @@ sub run_and_cmp
{
my ($dsc, $cmd, $out, $fout, $fexp) = @_;
$td->runtest($dsc,
- {$td->COMMAND => "$cmd --static-id"},
- {$td->STRING => $out,
- $td->EXIT_STATUS => 0});
+ {$td->COMMAND => "$cmd --static-id"},
+ {$td->STRING => $out,
+ $td->EXIT_STATUS => 0});
$td->runtest("$dsc output",
- {$td->COMMAND => "$qpdf --static-id" .
- " --no-original-object-ids -qdf $fout -"},
- {$td->FILE => $fexp,
- $td->EXIT_STATUS => 0});
+ {$td->COMMAND => "$qpdf --static-id" .
+ " --no-original-object-ids -qdf $fout -"},
+ {$td->FILE => $fexp,
+ $td->EXIT_STATUS => 0});
}
diff --git a/examples/qtest/name-number-tree.test b/examples/qtest/name-number-tree.test
index f3e433fd..e7fcf24e 100644
--- a/examples/qtest/name-number-tree.test
+++ b/examples/qtest/name-number-tree.test
@@ -12,13 +12,13 @@ my $td = new TestDriver('name-number-tree');
cleanup();
$td->runtest("name/number tree",
- {$td->COMMAND => 'pdf-name-number-tree a.pdf'},
- {$td->FILE => 'nn.out', $td->EXIT_STATUS => 0},
- $td->NORMALIZE_NEWLINES);
+ {$td->COMMAND => 'pdf-name-number-tree a.pdf'},
+ {$td->FILE => 'nn.out', $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->runtest("check output",
- {$td->FILE => "a.pdf"},
- {$td->FILE => "out.pdf"});
+ {$td->FILE => "a.pdf"},
+ {$td->FILE => "out.pdf"});
cleanup();
diff --git a/examples/qtest/npages.test b/examples/qtest/npages.test
index 191e8d8f..d41de55a 100644
--- a/examples/qtest/npages.test
+++ b/examples/qtest/npages.test
@@ -10,14 +10,14 @@ require TestDriver;
my $td = new TestDriver('pdf-npages');
$td->runtest("normal",
- {$td->COMMAND => "pdf-npages minimal.pdf"},
- {$td->STRING => "1\n", $td->EXIT_STATUS => 0},
- $td->NORMALIZE_NEWLINES);
+ {$td->COMMAND => "pdf-npages minimal.pdf"},
+ {$td->STRING => "1\n", $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->runtest("error",
- {$td->COMMAND => "pdf-npages bad"},
- {$td->REGEXP => "pdf-npages: bad: unable to find trailer.*",
- $td->EXIT_STATUS => 2},
- $td->NORMALIZE_NEWLINES);
+ {$td->COMMAND => "pdf-npages bad"},
+ {$td->REGEXP => "pdf-npages: bad: unable to find trailer.*",
+ $td->EXIT_STATUS => 2},
+ $td->NORMALIZE_NEWLINES);
$td->report(2);
diff --git a/examples/qtest/overlay-page.test b/examples/qtest/overlay-page.test
index a946b0ca..be9bcb10 100644
--- a/examples/qtest/overlay-page.test
+++ b/examples/qtest/overlay-page.test
@@ -12,18 +12,18 @@ my $td = new TestDriver('overlay-page');
cleanup();
$td->runtest("overlay-page",
- {$td->COMMAND => "pdf-overlay-page in.pdf stamp.pdf a.pdf"},
- {$td->STRING => "", $td->EXIT_STATUS => 0});
+ {$td->COMMAND => "pdf-overlay-page in.pdf stamp.pdf a.pdf"},
+ {$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("compare files",
- {$td->FILE => "a.pdf"},
- {$td->FILE => "out.pdf"});
+ {$td->FILE => "a.pdf"},
+ {$td->FILE => "out.pdf"});
$td->runtest("overlay-page with fields/ annotations",
- {$td->COMMAND => "pdf-overlay-page in.pdf annotations.pdf a.pdf"},
- {$td->STRING => "", $td->EXIT_STATUS => 0});
+ {$td->COMMAND => "pdf-overlay-page in.pdf annotations.pdf a.pdf"},
+ {$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("compare files",
- {$td->FILE => "a.pdf"},
- {$td->FILE => "annotations-out.pdf"});
+ {$td->FILE => "a.pdf"},
+ {$td->FILE => "annotations-out.pdf"});
cleanup();
diff --git a/examples/qtest/parse-content.test b/examples/qtest/parse-content.test
index a73566f8..6a9d94fc 100644
--- a/examples/qtest/parse-content.test
+++ b/examples/qtest/parse-content.test
@@ -10,8 +10,8 @@ require TestDriver;
my $td = new TestDriver('pdf-parse-content');
$td->runtest("parse content",
- {$td->COMMAND => "pdf-parse-content input.pdf 1"},
- {$td->FILE => "content.out", $td->EXIT_STATUS => 0},
- $td->NORMALIZE_NEWLINES);
+ {$td->COMMAND => "pdf-parse-content input.pdf 1"},
+ {$td->FILE => "content.out", $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->report(1);
diff --git a/examples/qtest/pdf-split-pages.test b/examples/qtest/pdf-split-pages.test
index ce271b35..05be22e0 100644
--- a/examples/qtest/pdf-split-pages.test
+++ b/examples/qtest/pdf-split-pages.test
@@ -12,16 +12,16 @@ my $td = new TestDriver('pdf-split-pages');
cleanup();
$td->runtest("split",
- {$td->COMMAND => "pdf-split-pages ' --static-id' in.pdf out"},
- {$td->STRING => "", $td->EXIT_STATUS => 0});
+ {$td->COMMAND => "pdf-split-pages ' --static-id' in.pdf out"},
+ {$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("check page 1",
- {$td->FILE => "out1.pdf"},
- {$td->FILE => "exp1.pdf"});
+ {$td->FILE => "out1.pdf"},
+ {$td->FILE => "exp1.pdf"});
$td->runtest("check page 2",
- {$td->FILE => "out2.pdf"},
- {$td->FILE => "exp2.pdf"});
+ {$td->FILE => "out2.pdf"},
+ {$td->FILE => "exp2.pdf"});
cleanup();
diff --git a/examples/qtest/qpdf-job.test b/examples/qtest/qpdf-job.test
index d3a490ab..c19cc260 100644
--- a/examples/qtest/qpdf-job.test
+++ b/examples/qtest/qpdf-job.test
@@ -12,8 +12,8 @@ cleanup();
my $td = new TestDriver('qpdf-job');
$td->runtest("qpdf-job",
- {$td->COMMAND => "qpdf-job"},
- {$td->FILE => "out", $td->EXIT_STATUS => 0},
+ {$td->COMMAND => "qpdf-job"},
+ {$td->FILE => "out", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
for (my $i = 1; $i <= 3; ++$i)
{
diff --git a/examples/qtest/qpdfjob-c.test b/examples/qtest/qpdfjob-c.test
index 33a55431..a01b2c64 100644
--- a/examples/qtest/qpdfjob-c.test
+++ b/examples/qtest/qpdfjob-c.test
@@ -12,12 +12,12 @@ cleanup();
my $td = new TestDriver('qpdfjob-c');
$td->runtest("qpdfjob-c",
- {$td->COMMAND => "qpdfjob-c in.pdf a.pdf"},
- {$td->STRING => "", $td->EXIT_STATUS => 0},
+ {$td->COMMAND => "qpdfjob-c in.pdf a.pdf"},
+ {$td->STRING => "", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
$td->runtest("check output",
- {$td->FILE => "a.pdf"},
- {$td->FILE => "out.pdf"});
+ {$td->FILE => "a.pdf"},
+ {$td->FILE => "out.pdf"});
cleanup();
diff --git a/examples/qtest/set-form-values.test b/examples/qtest/set-form-values.test
index 92f1cef1..8c103379 100644
--- a/examples/qtest/set-form-values.test
+++ b/examples/qtest/set-form-values.test
@@ -12,11 +12,11 @@ my $td = new TestDriver('pdf-set-form-values');
cleanup();
$td->runtest("set form values",
- {$td->COMMAND => "pdf-set-form-values form-in.pdf a.pdf soup"},
- {$td->STRING => "", $td->EXIT_STATUS => 0});
+ {$td->COMMAND => "pdf-set-form-values form-in.pdf a.pdf soup"},
+ {$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("compare files",
- {$td->FILE => "a.pdf"},
- {$td->FILE => "form-out.pdf"});
+ {$td->FILE => "a.pdf"},
+ {$td->FILE => "form-out.pdf"});
cleanup();