From 8887fe21f4ecb5c06bbb1b098f43c12d7851044e Mon Sep 17 00:00:00 2001 From: josch Date: Mon, 16 Feb 2015 19:09:34 +0100 Subject: [PATCH] print floats with four decimal places --- src/img2pdf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/img2pdf.py b/src/img2pdf.py index 5c1a87c..28bba81 100755 --- a/src/img2pdf.py +++ b/src/img2pdf.py @@ -45,8 +45,10 @@ def parse(cont, indent=1): return b"<<\n"+b"\n".join( [4 * indent * b" " + k.encode("utf8") + b" " + parse(v, indent+1) for k, v in sorted(cont.items())])+b"\n"+4*(indent-1)*b" "+b">>" - elif type(cont) is int or type(cont) is float: + elif type(cont) is int: return str(cont).encode("utf8") + elif type(cont) is float: + return ("%0.4f"%cont).encode("utf8") elif isinstance(cont, obj): return ("%d 0 R"%cont.identifier).encode("utf8") elif type(cont) is str: