forked from reingart/pyfpdf
-
Notifications
You must be signed in to change notification settings - Fork 329
Open
Labels
Description
Please explain your intent
When creating SVGs it is possible to combine elements into a group and apply a translate(x y) transformation to move them around the page. This operation to be missing from fpdf2's list of transformations?
Describe the solution you'd like
Similar to how rotations can be implemented by:
with pdf.rotation(angle, cx, cy):
draw_stuff()
A transform that can translate like:
with pdf.translate(dx, dy):
draw_stuff()
Additional context
I think this can be implemented using the same cm transform matrix as the other operations. I'm doing something like this as a work around for now:
@contextmanager
def pdf_translate(x,y):
with pdf.local_context():
pdf._out(
f"1 0 0 1 {x:.5f} {-y:.5f} cm"
)
yield