From 4f3b89991be466b77d1be2ab4fe0dc3f9228a17e Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 3 Apr 2020 16:48:20 -0400 Subject: placeFormXObject: allow control of shrink/expand (fixes #409) --- libqpdf/QPDFPageObjectHelper.cc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'libqpdf/QPDFPageObjectHelper.cc') diff --git a/libqpdf/QPDFPageObjectHelper.cc b/libqpdf/QPDFPageObjectHelper.cc index d6f1516e..8e0aac06 100644 --- a/libqpdf/QPDFPageObjectHelper.cc +++ b/libqpdf/QPDFPageObjectHelper.cc @@ -724,11 +724,12 @@ std::string QPDFPageObjectHelper::placeFormXObject( QPDFObjectHandle fo, std::string const& name, QPDFObjectHandle::Rectangle rect, - bool invert_transformations) + bool invert_transformations, + bool allow_shrink, bool allow_expand) { // Calculate the transformation matrix that will place the given - // form XObject fully inside the given rectangle, shrinking and - // centering if needed. + // form XObject fully inside the given rectangle, center and + // shrinking or expanding as needed if requested. // When rendering a form XObject, the transformation in the // graphics state (cm) is applied first (of course -- when it is @@ -797,7 +798,17 @@ QPDFPageObjectHelper::placeFormXObject( double scale = (xscale < yscale ? xscale : yscale); if (scale > 1.0) { - scale = 1.0; + if (! allow_expand) + { + scale = 1.0; + } + } + else if (scale < 1.0) + { + if (! allow_shrink) + { + scale = 1.0; + } } // Step 2: figure out what translation is required to get the -- cgit v1.2.3-54-g00ecf