Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add _addTransformationMatrix static method

PageObject._addTransformationMatrix adds a "cm" operator at the beginning of
a contents stream.

This is needed to implement content resizing.

Transformation matrices are defined in § 8.3.3 "Common Transformations" of
the PDF reference.

Patch from Kjo Hansi Glaz <kjo@a4nancy.net.eu.org>
  • Loading branch information...
commit 7aa3aadce07db016dba3759b724717632a8240a2 1 parent 6ce0636
@mfenniak authored
Showing with 11 additions and 0 deletions.
  1. +11 −0 pyPdf/pdf.py
View
11 pyPdf/pdf.py
@@ -959,6 +959,17 @@ def _pushPopGS(contents, pdf):
return stream
_pushPopGS = staticmethod(_pushPopGS)
+ def _addTransformationMatrix(contents, pdf, ctm):
+ # adds transformation matrix at the beginning of the given
+ # contents stream.
+ a, b, c, d, e, f = ctm
+ contents = ContentStream(contents, pdf)
+ contents.operations.insert(0, [[FloatObject(a), FloatObject(b),
+ FloatObject(c), FloatObject(d), FloatObject(e),
+ FloatObject(f)], " cm"])
+ return contents
+ _addTransformationMatrix = staticmethod(_addTransformationMatrix)
+
##
# Returns the /Contents object, or None if it doesn't exist.
# /Contents is optionnal, as described in PDF Reference 7.7.3.3
Please sign in to comment.
Something went wrong with that request. Please try again.