From f69ed209d093155e9921487056142370d0a6d0ce Mon Sep 17 00:00:00 2001 From: m-holger Date: Mon, 26 Sep 2022 19:29:26 +0100 Subject: Use QPDF::newStream in examples --- examples/pdf-attach-file.cc | 32 ++++++++++++++------------------ examples/pdf-create.cc | 4 ++-- examples/pdf-custom-filter.cc | 3 +-- examples/pdf-double-page-size.cc | 3 +-- examples/pdf-overlay-page.cc | 6 ++---- 5 files changed, 20 insertions(+), 28 deletions(-) (limited to 'examples') 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 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(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 -- cgit v1.2.3-54-g00ecf