Skip to content
Snippets Groups Projects
Commit 018330a8 authored by Frank Poetzsch-Heffter's avatar Frank Poetzsch-Heffter
Browse files

page numbering, comment out pdf-merging, sorting absence teachers

parent fdf3e267
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,10 @@ def generate_pdf(tex, filename):
bash_command = "pdflatex -halt-on-error -output-directory {} {}.tex".format(os.path.join(BASE_DIR, "latex"),
os.path.join(BASE_DIR, "latex",
filename))
# Execute two times to get number of last page
process = subprocess.Popen(bash_command.split(), stdout=subprocess.PIPE)
output = process.communicate()[0]
del output
process = subprocess.Popen(bash_command.split(), stdout=subprocess.PIPE)
output = process.communicate()[0]
del output
......
......@@ -337,28 +337,27 @@ def sub_pdf(request, plan_date=None):
tex += generate_class_tex_body(sub_table, date, header_info, hints)
tex += "\end{document}"
print(tex)
# Generate PDF
generate_pdf(tex, "aktuell")
# Merge PDFs
try:
merger = PdfFileMerger()
class0 = open(os.path.join(BASE_DIR, "latex", "aktuell0.pdf"), "rb")
class1 = open(os.path.join(BASE_DIR, "latex", "aktuell1.pdf"), "rb")
merger.append(fileobj=class0)
merger.append(fileobj=class1)
# Write merged PDF to aktuell.pdf
output = open(os.path.join(BASE_DIR, "latex", "aktuell.pdf"), "wb")
merger.write(output)
output.close()
# Register successful merge in debugging tool
register_return_0("merge_class", "pypdf2")
except Exception:
# Register exception in debugging tool
register_traceback("merge_class", "pypdf2")
# # Merge PDFs
# try:
# merger = PdfFileMerger()
# class0 = open(os.path.join(BASE_DIR, "latex", "aktuell0.pdf"), "rb")
# class1 = open(os.path.join(BASE_DIR, "latex", "aktuell1.pdf"), "rb")
# merger.append(fileobj=class0)
# merger.append(fileobj=class1)
#
# # Write merged PDF to aktuell.pdf
# output = open(os.path.join(BASE_DIR, "latex", "aktuell.pdf"), "wb")
# merger.write(output)
# output.close()
#
# # Register successful merge in debugging tool
# register_return_0("merge_class", "pypdf2")
# except Exception:
# # Register exception in debugging tool
# register_traceback("merge_class", "pypdf2")
# Read and response PDF
file = open(os.path.join(BASE_DIR, "latex", "aktuell.pdf"), "rb")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment