Minor cleanup
This commit is contained in:
parent
8d931f9570
commit
d4b49c510a
1 changed files with 5 additions and 3 deletions
|
@ -1075,7 +1075,7 @@ class pdfdoc(object):
|
||||||
self.tostream(stream)
|
self.tostream(stream)
|
||||||
return stream.getvalue()
|
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:
|
if self.engine == Engine.pikepdf:
|
||||||
PdfArray = pikepdf.Array
|
PdfArray = pikepdf.Array
|
||||||
PdfDict = pikepdf.Dictionary
|
PdfDict = pikepdf.Dictionary
|
||||||
|
@ -1271,6 +1271,8 @@ class pdfdoc(object):
|
||||||
return self.writer, self.output_version
|
return self.writer, self.output_version
|
||||||
|
|
||||||
# now write out the PDF
|
# 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:
|
if self.engine == Engine.pikepdf:
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
if pikepdf.__version__ >= "6.2.0":
|
if pikepdf.__version__ >= "6.2.0":
|
||||||
|
@ -2801,11 +2803,11 @@ def convert(*images, **kwargs):
|
||||||
)
|
)
|
||||||
|
|
||||||
if kwargs["outputstream"]:
|
if kwargs["outputstream"]:
|
||||||
pdf.tostream(kwargs["outputstream"])
|
pdf.tostream(outputstream=kwargs["outputstream"])
|
||||||
return
|
return
|
||||||
|
|
||||||
if kwargs["return_engine_doc"]:
|
if kwargs["return_engine_doc"]:
|
||||||
return pdf.tostream(None, return_engine_doc=True)
|
return pdf.tostream(return_engine_doc=True)
|
||||||
|
|
||||||
return pdf.tostring()
|
return pdf.tostring()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue