Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Add proper spacers to separate headers from content in the PDF

Roland Geider9dad52fc55c2
diff --git a/wger/manager/pdf.py b/wger/manager/pdf.py
index b6979b209..aaa2bef2e 100644
--- a/wger/manager/pdf.py
+++ b/wger/manager/pdf.py
@@ -27,7 +27,10 @@ from wger.manager.models import Workout
from wger.utils.pdf import styleSheet
from reportlab.lib.pagesizes import A4, cm
-from reportlab.platypus import Paragraph, SimpleDocTemplate, Table
+from reportlab.platypus import Paragraph
+from reportlab.platypus import SimpleDocTemplate
+from reportlab.platypus import Table
+from reportlab.platypus import Spacer
from reportlab.lib import colors
from wger import get_version
@@ -234,17 +237,13 @@ def workout_log(request, id):
elements.append(P)
# Filler
- P = Paragraph('<para> </para>', styleSheet["Normal"])
- elements.append(P)
+ elements.append(Spacer(10*cm, 0.5*cm))
# Append the table
elements.append(t)
- # Footer, add filler paragraph
- P = Paragraph('<para> </para>', styleSheet["Normal"])
- elements.append(P)
-
- # Print date and info
+ # Footer, date and info
+ elements.append(Spacer(10*cm, 0.5*cm))
created = datetime.date.today().strftime("%d.%m.%Y")
url = reverse('workout-view', kwargs={'id': workout.id})
P = Paragraph('''<para align="left">
@@ -436,17 +435,13 @@ def workout_view(request, id):
elements.append(p)
# Filler
- p = Paragraph('<para> </para>', styleSheet["Normal"])
- elements.append(p)
+ elements.append(Spacer(10*cm, 0.5*cm))
# Append the table
elements.append(t)
- # Footer, add filler paragraph
- p = Paragraph('<para> </para>', styleSheet["Normal"])
- elements.append(p)
-
- # Print date and info
+ # Footer, date and info
+ elements.append(Spacer(10*cm, 0.5*cm))
created = datetime.date.today().strftime("%d.%m.%Y")
url = reverse('workout-view', kwargs={'id': workout.id})
p = Paragraph('''<para align="left">
diff --git a/wger/nutrition/views/plan.py b/wger/nutrition/views/plan.py
index 7cec97f15..23b4abbed 100644
--- a/wger/nutrition/views/plan.py
+++ b/wger/nutrition/views/plan.py
@@ -28,8 +28,12 @@ from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy
from django.views.generic import DeleteView
from django.views.generic import UpdateView
+
from reportlab.lib.pagesizes import A4, cm
-from reportlab.platypus import Paragraph, SimpleDocTemplate, Table
+from reportlab.platypus import Paragraph
+from reportlab.platypus import SimpleDocTemplate
+from reportlab.platypus import Table
+from reportlab.platypus import Spacer
from reportlab.lib import colors
from wger.nutrition.models import NutritionPlan
@@ -257,8 +261,7 @@ def export_pdf(request, id):
elements.append(p)
# Filler
- p = Paragraph('<para> </para>', styleSheet["Normal"])
- elements.append(p)
+ elements.append(Spacer(10*cm, 0.5*cm))
# append the table to the document
elements.append(t)
@@ -309,10 +312,8 @@ def export_pdf(request, id):
t._argW[0] = 5 * cm
elements.append(t)
- # Footer, add filler paragraph
- elements.append(Paragraph('<para>&nbsp;</para>', styleSheet["Normal"]))
-
- # Print date and info
+ # Footer, date and info
+ elements.append(Spacer(10*cm, 0.5*cm))
created = datetime.date.today().strftime("%d.%m.%Y")
url = reverse('nutrition-view', kwargs={'id': plan.id})
p = Paragraph('''<para align="left">