convert(): add option to return the engine document handle
This commit is contained in:
parent
819b366bf5
commit
be313aa793
1 changed files with 8 additions and 1 deletions
|
@ -1075,7 +1075,7 @@ class pdfdoc(object):
|
|||
self.tostream(stream)
|
||||
return stream.getvalue()
|
||||
|
||||
def tostream(self, outputstream):
|
||||
def tostream(self, outputstream, return_engine_doc=False):
|
||||
if self.engine == Engine.pikepdf:
|
||||
PdfArray = pikepdf.Array
|
||||
PdfDict = pikepdf.Dictionary
|
||||
|
@ -1267,6 +1267,9 @@ class pdfdoc(object):
|
|||
self.writer.addobj(metadata)
|
||||
self.writer.addobj(iccstream)
|
||||
|
||||
if return_engine_doc:
|
||||
return self.writer, self.output_version
|
||||
|
||||
# now write out the PDF
|
||||
if self.engine == Engine.pikepdf:
|
||||
kwargs = {}
|
||||
|
@ -2634,6 +2637,7 @@ def convert(*images, **kwargs):
|
|||
viewer_center_window=False,
|
||||
viewer_fullscreen=False,
|
||||
outputstream=None,
|
||||
return_engine_doc=False,
|
||||
first_frame_only=False,
|
||||
allow_oversized=True,
|
||||
cropborder=None,
|
||||
|
@ -2800,6 +2804,9 @@ def convert(*images, **kwargs):
|
|||
pdf.tostream(kwargs["outputstream"])
|
||||
return
|
||||
|
||||
if kwargs["return_engine_doc"]:
|
||||
return pdf.tostream(None, return_engine_doc=True)
|
||||
|
||||
return pdf.tostring()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue