Minor cleanup

This commit is contained in:
mara004 2024-08-26 14:44:34 +02:00
parent 8d931f9570
commit d4b49c510a

View file

@ -1075,7 +1075,7 @@ class pdfdoc(object):
self.tostream(stream)
return stream.getvalue()
def tostream(self, outputstream, return_engine_doc=False):
def tostream(self, outputstream=None, return_engine_doc=False):
if self.engine == Engine.pikepdf:
PdfArray = pikepdf.Array
PdfDict = pikepdf.Dictionary
@ -1271,6 +1271,8 @@ class pdfdoc(object):
return self.writer, self.output_version
# now write out the PDF
if outputstream is None:
raise TypeError("pdfdoc.tostream() requires outputstream unless return_engine_doc is True.")
if self.engine == Engine.pikepdf:
kwargs = {}
if pikepdf.__version__ >= "6.2.0":
@ -2801,11 +2803,11 @@ def convert(*images, **kwargs):
)
if kwargs["outputstream"]:
pdf.tostream(kwargs["outputstream"])
pdf.tostream(outputstream=kwargs["outputstream"])
return
if kwargs["return_engine_doc"]:
return pdf.tostream(None, return_engine_doc=True)
return pdf.tostream(return_engine_doc=True)
return pdf.tostring()