Skip to content

Transformation manager to move #1689

@osresearch

Description

@osresearch

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions