Commit f69ed209d093155e9921487056142370d0a6d0ce

Authored by m-holger
Committed by Jay Berkenbilt
1 parent 9ebabd19

Use QPDF::newStream in examples

examples/pdf-attach-file.cc
... ... @@ -89,15 +89,13 @@ process(
89 89  
90 90 // Create appearance stream for the attachment.
91 91  
92   - auto ap = QPDFObjectHandle::newStream(
93   - &q,
94   - "0 10 m\n"
95   - "10 0 l\n"
96   - "20 10 l\n"
97   - "10 0 m\n"
98   - "10 20 l\n"
99   - "0 0 20 20 re\n"
100   - "S\n");
  92 + auto ap = q.newStream("0 10 m\n"
  93 + "10 0 l\n"
  94 + "20 10 l\n"
  95 + "10 0 m\n"
  96 + "10 20 l\n"
  97 + "0 0 20 20 re\n"
  98 + "S\n");
101 99 auto apdict = ap.getDict();
102 100  
103 101 // The following four lines demonstrate the use of the qpdf literal syntax
... ... @@ -127,15 +125,13 @@ process(
127 125 ">>")));
128 126  
129 127 // Generate contents for the page.
130   - auto contents = QPDFObjectHandle::newStream(
131   - &q,
132   - ("q\n"
133   - "BT\n"
134   - " 102 700 Td\n"
135   - " /F1 16 Tf\n"
136   - " (Here is an attachment.) Tj\n"
137   - "ET\n"
138   - "Q\n"));
  128 + auto contents = q.newStream(("q\n"
  129 + "BT\n"
  130 + " 102 700 Td\n"
  131 + " /F1 16 Tf\n"
  132 + " (Here is an attachment.) Tj\n"
  133 + "ET\n"
  134 + "Q\n"));
139 135  
140 136 // Create the page object.
141 137 auto page = QPDFObjectHandle::parse(
... ...
examples/pdf-create.cc
... ... @@ -139,7 +139,7 @@ createPageContents(QPDF& pdf, std::string const& text)
139 139 std::string contents = "BT /F1 24 Tf 72 320 Td (" + text +
140 140 ") Tj ET\n"
141 141 "q 244 0 0 144 184 100 cm /Im1 Do Q\n";
142   - return QPDFObjectHandle::newStream(&pdf, contents);
  142 + return pdf.newStream(contents);
143 143 }
144 144  
145 145 QPDFObjectHandle
... ... @@ -172,7 +172,7 @@ add_page(
172 172 std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p);
173 173 size_t width = p->getWidth();
174 174 size_t height = p->getHeight();
175   - QPDFObjectHandle image = QPDFObjectHandle::newStream(&pdf);
  175 + QPDFObjectHandle image = pdf.newStream();
176 176 auto image_dict =
177 177 // line-break
178 178 "<<"
... ...
examples/pdf-custom-filter.cc
... ... @@ -365,8 +365,7 @@ StreamReplacer::registerStream(
365 365 // or create objects during write.
366 366 char p[1] = {static_cast<char>(this->keys[og])};
367 367 std::string p_str(p, 1);
368   - QPDFObjectHandle dp_stream =
369   - QPDFObjectHandle::newStream(this->pdf, p_str);
  368 + QPDFObjectHandle dp_stream = this->pdf->newStream(p_str);
370 369 // Create /DecodeParms as expected by our fictitious
371 370 // /XORDecode filter.
372 371 QPDFObjectHandle decode_parms =
... ...
examples/pdf-double-page-size.cc
... ... @@ -75,8 +75,7 @@ main(int argc, char* argv[])
75 75  
76 76 for (auto& page: QPDFPageDocumentHelper(qpdf).getAllPages()) {
77 77 // Prepend the buffer to the page's contents
78   - page.addPageContents(
79   - QPDFObjectHandle::newStream(&qpdf, content), true);
  78 + page.addPageContents(qpdf.newStream(content), true);
80 79  
81 80 // Double the size of each of the content boxes
82 81 doubleBoxSize(page, "/MediaBox");
... ...
examples/pdf-overlay-page.cc
... ... @@ -57,10 +57,8 @@ stamp_page(char const* infile, char const* stampfile, char const* outfile)
57 57 // page's original content.
58 58 resources.mergeResources("<< /XObject << >> >>"_qpdf);
59 59 resources.getKey("/XObject").replaceKey(name, stamp_fo);
60   - ph.addPageContents(
61   - QPDFObjectHandle::newStream(&inpdf, "q\n"), true);
62   - ph.addPageContents(
63   - QPDFObjectHandle::newStream(&inpdf, "\nQ\n" + content), false);
  60 + ph.addPageContents(inpdf.newStream("q\n"), true);
  61 + ph.addPageContents(inpdf.newStream("\nQ\n" + content), false);
64 62 }
65 63 // Copy the annotations and form fields from the original page
66 64 // to the new page. For more efficiency when copying multiple
... ...
qpdf/pdf_from_scratch.cc
... ... @@ -22,8 +22,7 @@ usage()
22 22 static QPDFObjectHandle
23 23 createPageContents(QPDF& pdf, std::string const& text)
24 24 {
25   - std::string contents = "BT /F1 15 Tf 72 720 Td (" + text + ") Tj ET\n";
26   - return QPDFObjectHandle::newStream(&pdf, contents);
  25 + return pdf.newStream("BT /F1 15 Tf 72 720 Td (" + text + ") Tj ET\n");
27 26 }
28 27  
29 28 QPDFObjectHandle
... ...