diff --git a/biscuit/apps/chronos/pdf.py b/biscuit/apps/chronos/pdf.py index 3b921bb13bca055edbf00516d85640afa7051b20..255b99f71c7bafdacadb43decc30afaa7c019f1f 100644 --- a/biscuit/apps/chronos/pdf.py +++ b/biscuit/apps/chronos/pdf.py @@ -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 diff --git a/biscuit/apps/chronos/views.py b/biscuit/apps/chronos/views.py index c13d81176096c3cd0eef5a11f3ab0ca5dc982f27..b0a7b6be4f260609cbe161fb67f905aec14b506c 100755 --- a/biscuit/apps/chronos/views.py +++ b/biscuit/apps/chronos/views.py @@ -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")