I'm using pycairo to render PDF's with the PDFSurface in a function called in a loop. Something like:
def render_PDF(args):
with cairo.PDFSurface(path, width, height) as surface:
context = cairo.Context(surface)
# call Cairo rendering methods
# ...
context.show_page()
In main.py:
for args in something:
render_PDF(args)
This is running a much larger application where the args and other settings are coming from. For some reason the generated PDF's are combined together, with the first PDF with one page, the second with two overlaid pages, the third with three overlaid pages etc.
It doesn't seem to matter whether I use the Python "with" approach or manually flush and finish the surface, the PDF's are still combined.
This must be something I'm doing wrong or not appreciating about Python scopes?
I'm using pycairo to render PDF's with the PDFSurface in a function called in a loop. Something like:
In main.py:
This is running a much larger application where the
args
and other settings are coming from. For some reason the generated PDF's are combined together, with the first PDF with one page, the second with two overlaid pages, the third with three overlaid pages etc.It doesn't seem to matter whether I use the Python "with" approach or manually flush and finish the surface, the PDF's are still combined.
This must be something I'm doing wrong or not appreciating about Python scopes?