Browse Source

with pdf scores

master
zeroth 4 years ago
parent
commit
c54b9c646b
  1. 24
      contextualise.py
  2. 31
      static/css/stylepandoc.css

24
contextualise.py

@ -304,6 +304,7 @@ def get_file():
###### SCORE FIST PAGE ###### SCORE FIST PAGE
globalname = "Pushing scores" globalname = "Pushing scores"
print(tadam)
scorefirstpage = '''<!DOCTYPE html> scorefirstpage = '''<!DOCTYPE html>
<html> <html>
@ -313,13 +314,15 @@ def get_file():
</head> </head>
<body> <body>
<style> <style>
body{background-color:yellow;} body{background-color:magenta;}
</style> </style>
<div id="coverpage"> <div id="coverpage">
<div>'''+globalname+'''</div> <div class="infos scorenumber">SCORE #'''+str(scorenumber)+'''</div>
<div>'''+str(scorenumber)+'''</div> <div class="infos author">By '''+userip+'''</div>
<div>'''+str(clickongetfiletime)+'''</div> <!--<div class="infos globalname">Part of the Pushing Scores series</div>-->
<div>'''+userip+'''</div> <div class="infos publisher">Part of the <i>Pushing Scores</i> series<br>
Published and distributed by <img src="static/logo/logo.png"></div>
<div class="infos time">On '''+str(clickongetfiletime)+'''</div>
</div> </div>
</body> </body>
</html> </html>
@ -341,13 +344,13 @@ def get_file():
############# GENERATE SCORE PDF ############# GENERATE SCORE PDF
pathnamefilepdf = "pandoc/"+uniquename+"test.pdf" pathnamefilepdf = "scores/"+uniquename+"test.pdf"
font_config = FontConfiguration() 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) 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 ############# GENERATE FIRST PAGE PDF
pathnamefilecoverpdf = "pandoc/"+uniquename+"testcover.pdf" pathnamefilecoverpdf = "scores/"+uniquename+"testcover.pdf"
font_config = FontConfiguration() 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) 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() pdf1_pages = pdf1.getNumPages()
pdf2_pages = pdf2.getNumPages() pdf2_pages = pdf2.getNumPages()
outputfile = open("pandoc/"+uniquename+"document-output.pdf", "wb") outputfile = open("scores/"+uniquename+".pdf", "wb")
writer = PyPDF2.PdfFileWriter() writer = PyPDF2.PdfFileWriter()
for i in range(pdf1_pages): for i in range(pdf1_pages):
@ -379,9 +382,12 @@ def get_file():
outputfile.close() outputfile.close()
clearSession() clearSession()
os.remove(pathnamefilecoverpdf)
os.remove(pathnamefilepdf)
print("files removed")
try: 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: except Exception as e:
return str(e) return str(e)

31
static/css/stylepandoc.css

@ -14,14 +14,39 @@ html,body{
text-align: center; text-align: center;
} }
div#coverpage{ div#coverpage{
/*background-color: red;*/
height: 100%; height: 100%;
width: 100%; width: 100%;
margin: 0 /*margin: 0;*/
/*background-color: silver;*/
} }
div#scorecontentpage{ div#scorecontentpage{
margin:auto; margin:auto;
color: black; 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;
} }
Loading…
Cancel
Save