aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2022-09-26 20:29:26 +0200
committerJay Berkenbilt <jberkenbilt@users.noreply.github.com>2022-11-19 20:10:42 +0100
commitf69ed209d093155e9921487056142370d0a6d0ce (patch)
tree9778601b165d4fde804f56671051423cfbbecab8
parent9ebabd19538512b6515696b164a17b90060a75c3 (diff)
downloadqpdf-f69ed209d093155e9921487056142370d0a6d0ce.tar.zst
Use QPDF::newStream in examples
-rw-r--r--examples/pdf-attach-file.cc32
-rw-r--r--examples/pdf-create.cc4
-rw-r--r--examples/pdf-custom-filter.cc3
-rw-r--r--examples/pdf-double-page-size.cc3
-rw-r--r--examples/pdf-overlay-page.cc6
-rw-r--r--qpdf/pdf_from_scratch.cc3
6 files changed, 21 insertions, 30 deletions
diff --git a/examples/pdf-attach-file.cc b/examples/pdf-attach-file.cc
index c04f5b9f..9cb55741 100644
--- a/examples/pdf-attach-file.cc
+++ b/examples/pdf-attach-file.cc
@@ -89,15 +89,13 @@ process(
// Create appearance stream for the attachment.
- auto ap = QPDFObjectHandle::newStream(
- &q,
- "0 10 m\n"
- "10 0 l\n"
- "20 10 l\n"
- "10 0 m\n"
- "10 20 l\n"
- "0 0 20 20 re\n"
- "S\n");
+ auto ap = q.newStream("0 10 m\n"
+ "10 0 l\n"
+ "20 10 l\n"
+ "10 0 m\n"
+ "10 20 l\n"
+ "0 0 20 20 re\n"
+ "S\n");
auto apdict = ap.getDict();
// The following four lines demonstrate the use of the qpdf literal syntax
@@ -127,15 +125,13 @@ process(
">>")));
// Generate contents for the page.
- auto contents = QPDFObjectHandle::newStream(
- &q,
- ("q\n"
- "BT\n"
- " 102 700 Td\n"
- " /F1 16 Tf\n"
- " (Here is an attachment.) Tj\n"
- "ET\n"
- "Q\n"));
+ auto contents = q.newStream(("q\n"
+ "BT\n"
+ " 102 700 Td\n"
+ " /F1 16 Tf\n"
+ " (Here is an attachment.) Tj\n"
+ "ET\n"
+ "Q\n"));
// Create the page object.
auto page = QPDFObjectHandle::parse(
diff --git a/examples/pdf-create.cc b/examples/pdf-create.cc
index f730b743..527243a7 100644
--- a/examples/pdf-create.cc
+++ b/examples/pdf-create.cc
@@ -139,7 +139,7 @@ createPageContents(QPDF& pdf, std::string const& text)
std::string contents = "BT /F1 24 Tf 72 320 Td (" + text +
") Tj ET\n"
"q 244 0 0 144 184 100 cm /Im1 Do Q\n";
- return QPDFObjectHandle::newStream(&pdf, contents);
+ return pdf.newStream(contents);
}
QPDFObjectHandle
@@ -172,7 +172,7 @@ add_page(
std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p);
size_t width = p->getWidth();
size_t height = p->getHeight();
- QPDFObjectHandle image = QPDFObjectHandle::newStream(&pdf);
+ QPDFObjectHandle image = pdf.newStream();
auto image_dict =
// line-break
"<<"
diff --git a/examples/pdf-custom-filter.cc b/examples/pdf-custom-filter.cc
index 2ea5fd42..2310a687 100644
--- a/examples/pdf-custom-filter.cc
+++ b/examples/pdf-custom-filter.cc
@@ -365,8 +365,7 @@ StreamReplacer::registerStream(
// or create objects during write.
char p[1] = {static_cast<char>(this->keys[og])};
std::string p_str(p, 1);
- QPDFObjectHandle dp_stream =
- QPDFObjectHandle::newStream(this->pdf, p_str);
+ QPDFObjectHandle dp_stream = this->pdf->newStream(p_str);
// Create /DecodeParms as expected by our fictitious
// /XORDecode filter.
QPDFObjectHandle decode_parms =
diff --git a/examples/pdf-double-page-size.cc b/examples/pdf-double-page-size.cc
index fb0584e9..1ebe71df 100644
--- a/examples/pdf-double-page-size.cc
+++ b/examples/pdf-double-page-size.cc
@@ -75,8 +75,7 @@ main(int argc, char* argv[])
for (auto& page: QPDFPageDocumentHelper(qpdf).getAllPages()) {
// Prepend the buffer to the page's contents
- page.addPageContents(
- QPDFObjectHandle::newStream(&qpdf, content), true);
+ page.addPageContents(qpdf.newStream(content), true);
// Double the size of each of the content boxes
doubleBoxSize(page, "/MediaBox");
diff --git a/examples/pdf-overlay-page.cc b/examples/pdf-overlay-page.cc
index d055d279..04a1e921 100644
--- a/examples/pdf-overlay-page.cc
+++ b/examples/pdf-overlay-page.cc
@@ -57,10 +57,8 @@ stamp_page(char const* infile, char const* stampfile, char const* outfile)
// page's original content.
resources.mergeResources("<< /XObject << >> >>"_qpdf);
resources.getKey("/XObject").replaceKey(name, stamp_fo);
- ph.addPageContents(
- QPDFObjectHandle::newStream(&inpdf, "q\n"), true);
- ph.addPageContents(
- QPDFObjectHandle::newStream(&inpdf, "\nQ\n" + content), false);
+ ph.addPageContents(inpdf.newStream("q\n"), true);
+ ph.addPageContents(inpdf.newStream("\nQ\n" + content), false);
}
// Copy the annotations and form fields from the original page
// to the new page. For more efficiency when copying multiple
diff --git a/qpdf/pdf_from_scratch.cc b/qpdf/pdf_from_scratch.cc
index 0cef5de3..bdcdaae1 100644
--- a/qpdf/pdf_from_scratch.cc
+++ b/qpdf/pdf_from_scratch.cc
@@ -22,8 +22,7 @@ usage()
static QPDFObjectHandle
createPageContents(QPDF& pdf, std::string const& text)
{
- std::string contents = "BT /F1 15 Tf 72 720 Td (" + text + ") Tj ET\n";
- return QPDFObjectHandle::newStream(&pdf, contents);
+ return pdf.newStream("BT /F1 15 Tf 72 720 Td (" + text + ") Tj ET\n");
}
QPDFObjectHandle