From cfdfe5f23e1913ae6c577ca4288aeda8d1bc370f Mon Sep 17 00:00:00 2001 From: wvengen Date: Sat, 3 Jan 2015 00:06:44 +0100 Subject: [PATCH] Improve header+footer in PDFs --- config/locales/de.yml | 2 +- config/locales/en.yml | 2 +- config/locales/fr.yml | 2 +- config/locales/nl.yml | 2 +- lib/order_pdf.rb | 14 ++++++++++++-- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/config/locales/de.yml b/config/locales/de.yml index 109351ff..ade556a0 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -1003,7 +1003,7 @@ de: logo: "foodsoft" lib: order_pdf: - page: Seite %{number} + page: Seite %{number} von %{count} login: accept_invitation: body: "

Du bist eingeladen worden als Mitglied der Gruppe %{group} in der Foodcoop %{foodcoop} mitzumachen.

Wenn Du mitmachen möchtest, dann fülle bitte dieses Formular aus.

Deine Daten werden selbstverständlich nicht an Dritte, aus was auch immer für Gründen, weitergeben. Du kannst auch entscheiden, wieviel deiner persönlichen Daten für alle einsehbar sein sollen. 'Alle' bedeutet hier alle Foodcoop-Mitglieder. Die Administratoren haben aber jederzeit Zugriff auf deine Daten.

" diff --git a/config/locales/en.yml b/config/locales/en.yml index 0c112dd3..1cd1c711 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1005,7 +1005,7 @@ en: logo: "foodsoft" lib: order_pdf: - page: Page %{number} + page: Page %{number} of %{count} login: accept_invitation: body: "

You are invited to be part of the foodcoop %{foodcoop} as a member of the group %{group}.

If you want to participate, please fill in this form.

Naturally, your information wll not be shared with third parties for any reason. You can decide how much of your personal information should be visible for everyone. 'All' means all Foodcoop-members. Please note that the administrators do have access to your information.

" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 8824e61d..c13a6747 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -1016,7 +1016,7 @@ fr: logo: coop lib: order_pdf: - page: page %{number} + page: page %{number} de %{count} login: accept_invitation: body: | diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 79f62a37..d361b78a 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -1005,7 +1005,7 @@ nl: logo: "foodsoft" lib: order_pdf: - page: Pagina %{number} + page: Pagina %{number} van %{count} login: accept_invitation: body: "

Je bent uitgenodigd als lid voor foodcoop %{foodcoop} in de groep %{group}.

Als je wilt meedoen, vul dan dit formulier in.

Natuurlijk zullen we je informatie niet delen met anderen. Je kunt zelf aangeven, welke informatie voor andere leden beschikbaar is (maar beheerders hebben daar altijd toegang toe).

" diff --git a/lib/order_pdf.rb b/lib/order_pdf.rb index 81f2b8d0..1d62f837 100644 --- a/lib/order_pdf.rb +++ b/lib/order_pdf.rb @@ -20,8 +20,18 @@ class OrderPdf < Prawn::Document # Define header repeat :all, dynamic: true do - draw_text title, size: fontsize(10), style: :bold, at: [bounds.left, bounds.top+20] if title # Header - draw_text I18n.t('lib.order_pdf.page', :number => page_number), size: fontsize(8), at: [bounds.left, bounds.bottom-10] # Footer + s = fontsize(8) + # header + bounding_box [bounds.left, bounds.top+s*2], width: bounds.width, height: s*1.2 do + text title, size: s, align: :center if title + end + # footer + bounding_box [bounds.left, bounds.bottom-s], width: bounds.width, height: s*1.2 do + text I18n.t('lib.order_pdf.page', number: page_number, count: page_count), size: s, align: :right + end + bounding_box [bounds.left, bounds.bottom-s], width: bounds.width, height: s*1.2 do + text I18n.l(Time.now, format: :long), size: s, align: :left + end end body # Add content, which is defined in subclasses