From ab9d557cb051b3568add22790cc58143c823e8df Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 29 Apr 2022 20:39:54 -0400 Subject: Use fluent replaceKey --- examples/pdf-attach-file.cc | 8 ++++---- examples/pdf-create.cc | 15 +++++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'examples') diff --git a/examples/pdf-attach-file.cc b/examples/pdf-attach-file.cc index eb12a002..0d15122f 100644 --- a/examples/pdf-attach-file.cc +++ b/examples/pdf-attach-file.cc @@ -106,10 +106,10 @@ process( // apdict.replaceKey("/Type", QPDFObjectHandle::newName("/XObject")); // apdict.replaceKey("/Subtype", QPDFObjectHandle::newName("/Form")); // apdict.replaceKey("/BBox", QPDFObjectHandle::parse("[ 0 0 20 20 ]")); - apdict.replaceKey("/Resources", "<< >>"_qpdf); - apdict.replaceKey("/Type", "/XObject"_qpdf); - apdict.replaceKey("/Subtype", "/Form"_qpdf); - apdict.replaceKey("/BBox", "[ 0 0 20 20 ]"_qpdf); + apdict.replaceKey("/Resources", "<< >>"_qpdf) + .replaceKey("/Type", "/XObject"_qpdf) + .replaceKey("/Subtype", "/Form"_qpdf) + .replaceKey("/BBox", "[ 0 0 20 20 ]"_qpdf); auto annot = q.makeIndirectObject(QPDFObjectHandle::parse( &q, ("<<" diff --git a/examples/pdf-create.cc b/examples/pdf-create.cc index b5adb01a..ea315a49 100644 --- a/examples/pdf-create.cc +++ b/examples/pdf-create.cc @@ -183,9 +183,9 @@ add_page( " /Subtype /Image" " /BitsPerComponent 8" ">>"_qpdf; - image_dict.replaceKey("/ColorSpace", newName(color_space)); - image_dict.replaceKey("/Width", newInteger(width)); - image_dict.replaceKey("/Height", newInteger(height)); + image_dict.replaceKey("/ColorSpace", newName(color_space)) + .replaceKey("/Width", newInteger(width)) + .replaceKey("/Height", newInteger(height)); image.replaceDict(image_dict); // Provide the stream data. @@ -202,9 +202,9 @@ add_page( xobject.replaceKey("/Im1", image); QPDFObjectHandle resources = QPDFObjectHandle::newDictionary(); - resources.replaceKey("/ProcSet", procset); - resources.replaceKey("/Font", rfont); - resources.replaceKey("/XObject", xobject); + resources.replaceKey("/ProcSet", procset) + .replaceKey("/Font", rfont) + .replaceKey("/XObject", xobject); // Create the page content stream QPDFObjectHandle contents = @@ -215,8 +215,7 @@ add_page( " /Type /Page" " /MediaBox [0 0 612 392]" ">>"_qpdf); - page.replaceKey("/Contents", contents); - page.replaceKey("/Resources", resources); + page.replaceKey("/Contents", contents).replaceKey("/Resources", resources); // Add the page to the PDF file dh.addPage(page, false); -- cgit v1.2.3-54-g00ecf