From c54b9c646b5cd3b564edcd372fe0f4e3168d605b Mon Sep 17 00:00:00 2001 From: zeroth Date: Thu, 16 Jan 2020 22:14:01 +0000 Subject: [PATCH] with pdf scores --- contextualise.py | 24 +++++++++++++++--------- static/css/stylepandoc.css | 31 ++++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/contextualise.py b/contextualise.py index 322472f..8dc456b 100644 --- a/contextualise.py +++ b/contextualise.py @@ -304,6 +304,7 @@ def get_file(): ###### SCORE FIST PAGE globalname = "Pushing scores" + print(tadam) scorefirstpage = ''' @@ -313,13 +314,15 @@ def get_file():
-
'''+globalname+'''
-
'''+str(scorenumber)+'''
-
'''+str(clickongetfiletime)+'''
-
'''+userip+'''
+
SCORE #'''+str(scorenumber)+'''
+
By '''+userip+'''
+ +
Part of the Pushing Scores series
+ Published and distributed by
+
On '''+str(clickongetfiletime)+'''
@@ -341,13 +344,13 @@ def get_file(): ############# GENERATE SCORE PDF - pathnamefilepdf = "pandoc/"+uniquename+"test.pdf" + pathnamefilepdf = "scores/"+uniquename+"test.pdf" font_config = FontConfiguration() HTML(string=scorecontentpage, base_url='./').write_pdf(pathnamefilepdf, stylesheets=[CSS('static/css/stylepandoc.css', font_config=font_config)], font_config=font_config) ############# GENERATE FIRST PAGE PDF - pathnamefilecoverpdf = "pandoc/"+uniquename+"testcover.pdf" + pathnamefilecoverpdf = "scores/"+uniquename+"testcover.pdf" font_config = FontConfiguration() HTML(string=scorefirstpage, base_url='./').write_pdf(pathnamefilecoverpdf, stylesheets=[CSS('static/css/stylepandoc.css', font_config=font_config)], font_config=font_config) @@ -363,7 +366,7 @@ def get_file(): pdf1_pages = pdf1.getNumPages() pdf2_pages = pdf2.getNumPages() - outputfile = open("pandoc/"+uniquename+"document-output.pdf", "wb") + outputfile = open("scores/"+uniquename+".pdf", "wb") writer = PyPDF2.PdfFileWriter() for i in range(pdf1_pages): @@ -379,9 +382,12 @@ def get_file(): outputfile.close() clearSession() + os.remove(pathnamefilecoverpdf) + os.remove(pathnamefilepdf) + print("files removed") try: - return send_file("pandoc/"+uniquename+"document-output.pdf", attachment_filename="olala.pdf") + return send_file("scores/"+uniquename+".pdf", attachment_filename="olala.pdf") except Exception as e: return str(e) diff --git a/static/css/stylepandoc.css b/static/css/stylepandoc.css index 228efcd..42e1657 100644 --- a/static/css/stylepandoc.css +++ b/static/css/stylepandoc.css @@ -14,14 +14,39 @@ html,body{ text-align: center; } div#coverpage{ - /*background-color: red;*/ height: 100%; width: 100%; - margin: 0 + /*margin: 0;*/ + /*background-color: silver;*/ } div#scorecontentpage{ margin:auto; color: black; - /*text-align: left;*/ + text-align: center; + width: 70%; +} +div.scorenumber{ + font-size: 3em; + /*background-color: silver;*/ + margin: 50% auto 0 auto; + width: 50%; + border: 0.5mm solid black; + padding:2mm 0 2mm 0; + /*position: fixed;*/ +} +img{ + max-width: 20mm; +} +div.author{ + margin-top: 5%; + font-size: 1.5em; +} +div.publisher{ + margin-bottom: : 3mm; + margin-top: 60%; + +} +div.time{ + margin-top: 1mm; } \ No newline at end of file