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
globalname = "Pushing scores"
print(tadam)
scorefirstpage = '''<!DOCTYPE html>
<html>
@ -313,13 +314,15 @@ def get_file():
</head>
<body>
<style>
body{background-color:yellow;}
body{background-color:magenta;}
</style>
<div id="coverpage">
<div>'''+globalname+'''</div>
<div>'''+str(scorenumber)+'''</div>
<div>'''+str(clickongetfiletime)+'''</div>
<div>'''+userip+'''</div>
<div class="infos scorenumber">SCORE #'''+str(scorenumber)+'''</div>
<div class="infos author">By '''+userip+'''</div>
<!--<div class="infos globalname">Part of the Pushing Scores series</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>
</body>
</html>
@ -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)

31
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;
}
Loading…
Cancel
Save