aboutsummaryrefslogtreecommitdiffstats
path: root/examples/pdf-double-page-size.cc
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/pdf-double-page-size.cc
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/pdf-double-page-size.cc')
-rw-r--r--examples/pdf-double-page-size.cc82
1 files changed, 41 insertions, 41 deletions
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;