From f02aa74bf5387c30e4ff6082beeb4b0d078b6294 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Mon, 22 Feb 2021 16:09:02 -0500 Subject: Update pdf-overlay-page example to copy annotations --- examples/pdf-overlay-page.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'examples/pdf-overlay-page.cc') diff --git a/examples/pdf-overlay-page.cc b/examples/pdf-overlay-page.cc index 88722352..1e06c40c 100644 --- a/examples/pdf-overlay-page.cc +++ b/examples/pdf-overlay-page.cc @@ -56,9 +56,10 @@ static void stamp_page(char const* infile, // Generate content to place the form XObject centered within // destination page's trim box. + QPDFMatrix m; std::string content = ph.placeFormXObject( - stamp_fo, name, ph.getTrimBox().getArrayAsRectangle()); + stamp_fo, name, ph.getTrimBox().getArrayAsRectangle(), m); if (! content.empty()) { // Append the content to the page's content. Surround the @@ -72,6 +73,11 @@ static void stamp_page(char const* infile, ph.addPageContents( QPDFObjectHandle::newStream(&inpdf, "\nQ\n" + content), false); } + // Copy the annotations and form fields from the original page + // to the new page. For more efficiency when copying multiple + // pages, we can create a QPDFAcroFormDocumentHelper and pass + // it in. See comments in QPDFPageObjectHelper.hh for details. + ph.copyAnnotations(stamp_page_1, m); } QPDFWriter w(inpdf, outfile); -- cgit v1.2.3-54-g00ecf