diff options
author | Jay Berkenbilt <ejb@ql.org> | 2020-04-03 22:48:20 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2020-04-04 03:39:17 +0200 |
commit | 4f3b89991be466b77d1be2ab4fe0dc3f9228a17e (patch) | |
tree | 30381f6344548f26a3e2b2b29e57a4ea53c23001 /libqpdf | |
parent | b76b73b229c0d8111c13c9179ad97d3bfd1e1c7c (diff) | |
download | qpdf-4f3b89991be466b77d1be2ab4fe0dc3f9228a17e.tar.zst |
placeFormXObject: allow control of shrink/expand (fixes #409)
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/QPDFPageObjectHelper.cc | 19 |
1 files changed, 15 insertions, 4 deletions
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 |