diff --git a/app/assets/images/logo-apfelschule.png b/app/assets/images/logo-apfelschule.png
index 475c455..d603a48 100644
Binary files a/app/assets/images/logo-apfelschule.png and b/app/assets/images/logo-apfelschule.png differ
diff --git a/app/assets/images/logo-apfelschule_xs.png b/app/assets/images/logo-apfelschule_xs.png
new file mode 100644
index 0000000..d9d46ff
Binary files /dev/null and b/app/assets/images/logo-apfelschule_xs.png differ
diff --git a/app/models/pdf_documents/base.rb b/app/models/pdf_documents/base.rb
index 32703da..8484f62 100644
--- a/app/models/pdf_documents/base.rb
+++ b/app/models/pdf_documents/base.rb
@@ -45,8 +45,8 @@ module PdfDocuments
@prawn_document.markup "
#{text}
"
end
- def text(text)
- @prawn_document.text text, markup_options[:text]
+ def text(text, **args)
+ @prawn_document.text text, markup_options[:text].merge(args)
end
def rich_text(text)
@@ -69,8 +69,8 @@ module PdfDocuments
}
end
- def logo
- @prawn_document.image "app/assets/images/logo-apfelschule.png", width: 150
+ def logo(width: 24, xs: true)
+ @prawn_document.image "app/assets/images/logo-apfelschule#{ xs ? "_xs" : "" }.png", width:
end
def prepare_rich_text(rich_text)
@@ -81,6 +81,7 @@ module PdfDocuments
rich_text.sub(/(
)+$/, "")
end
+ # @prawn_document.draw_text("Dokument erstellt am #{Time.current.strftime('%d %B %Y')} um #{Time.current.strftime('%H:%M:%S')}", at: [ 0, -15 ])
def font(...)
@prawn_document.font(...)
diff --git a/app/models/pdf_documents/customer_report.rb b/app/models/pdf_documents/customer_report.rb
index 95a0154..0cf4b92 100644
--- a/app/models/pdf_documents/customer_report.rb
+++ b/app/models/pdf_documents/customer_report.rb
@@ -5,16 +5,34 @@ module PdfDocuments
private
def generate
+ move_down 130
+ logo(width: 250, xs: false)
+ move_down 40
heading1 params.report.name
- rich_text params.report.comment
+
+ move_down 20
+ @prawn_document.text "#{I18n.l params.report.updated_at.to_date, format: :long}"
+ move_down 40
+ safe_display(params.report.comment) do
+ rich_text _1
+ move_down 30
+ end
+
+ @prawn_document.font_size(8) do
+ @prawn_document.draw_text("Dokument erstellt am #{Time.current.strftime('%d %B %Y')} um #{Time.current.strftime('%H:%M:%S')}", at: [0, 0])
+ end
+ @prawn_document.start_new_page
@pages = {}
params.report.export[:elements].each.with_index(1) do |(element, success_criteria), element_index|
new_page(required_space: 200) if element_index > 1
without_page_break do
heading2 "#{element_index} #{element.title}"
- bold("#{element.page.path}")
- safe_display(element.screenshot) { image(_1.variant(:thumbnail), height: 160) && move_down(5) }
+ @prawn_document.text("Pfad: #{element.page.path}", inline_format: true)
+ safe_display(element.screenshot) do
+ image(_1.variant(:thumbnail), height: 160)
+ move_down(15)
+ end
end
rich_text element.description
move_down(10)
@@ -24,17 +42,71 @@ module PdfDocuments
success_criterion_row(success_criterion, [ element_index, sc_index ])
end
end
+
+ @prawn_document.start_new_page
+ heading1("Anhang: Richtlinien")
+ params.report.export[:success_criteria].group_by(&:check).sort_by{ |c, _scs| c.external_number }.each do |check, criteria|
+ heading2(check.display_label)
+ {
+ external_number: { label: "WCAG Nummer" },
+ external_url: { label: "WCAG Link" },
+ conformity_level: { label: "Konformität" },
+ conformity_notice_de: { label: "Anmerkung Konformität", rich: true },
+ priority: { label: "Priorität" },
+ criterion_de: { label: "Kriterium/Grundlage", rich: true },
+ exemption_details_de: { label: "Ausnahmen", rich: true },
+ criterion_details_de: { label: "Verstehen", rich: true },
+ example_de: { label: "Beispiel", rich: true },
+ annotation_de: { label: "Anmerkung", rich: true }
+ }.each do |attribute, options|
+ v = check.send(attribute)
+ safe_display(v) do
+ text("#{options[:label]}", inline_format: true)
+ if options[:rich]
+ rich_text(_1)
+ else
+ text(_1)
+ end
+ end
+ end
+
+ if check.links.any?
+ text("Links", inline_format: true)
+ check.links.group_by(&:link_category).each do |cat, links|
+ text(%Q(
+ #{cat.name}
+
+ #{links.map{ "#{_1.text}" }.join() }
+
+ ))
+ end
+ end
+
+ text("Erfolgskriterien", inline_format: true)
+ text criteria.map(&:number).sort.join(", ")
+ end
string = "Seite / "
# Green page numbers 1 to 7
options = {
- at: [ @prawn_document.bounds.right - 150, -10 ],
+ at: [ @prawn_document.bounds.right - 150, 776 ],
width: 150,
align: :right,
- start_count_at: 1
+ start_count_at: 2,
+ page_filter: ->(x) { x > 1 }
}
@prawn_document.number_pages string, options
- @prawn_document.repeat(:all) do
+ @prawn_document.repeat(2..) do
+ @prawn_document.text_box "#{params.report.name}", at: [ 50, 777 ], inline_format: true, width: 300
+ # @prawn_document.text_box "#{I18n.l params.report.updated_at.to_date, format: :long}", at: [ 0, 777 ], inline_format: true, width: 532, align: :right
+ @prawn_document.bounding_box([0, 766], width: 532) do
+ hr
+ end
+ @prawn_document.bounding_box([0, 796], width: 200, height: 200) do
+ logo
+ end
+ end
+ @prawn_document.repeat(2..) do
# @prawn_document.bounding_box([ 0, 790 ], width: 200) do
# logo
# end
@@ -46,20 +118,13 @@ module PdfDocuments
# at: [ 0, -15 ],
# width: 200
# )
- @prawn_document.text_box "#{params.report.name}", at: [ 150, 777 ], inline_format: true, width: 300
- @prawn_document.text_box "#{I18n.l params.report.updated_at.to_date, format: :long}", at: [ 0, 777 ], inline_format: true, width: 516, align: :right
- @prawn_document.bounding_box([-10, 800], width: 200, height: 200) do
- logo
- end
+ # @prawn_document.text_box "#{I18n.l params.report.updated_at.to_date, format: :long}", at: [ 0, 777 ], inline_format: true, width: 532, align: :right
@prawn_document.font_size(8) do
- @prawn_document.draw_text("Dieses Dokument wurd am #{Time.current.strftime('%d %B %Y')} um #{Time.current.strftime('%H:%M:%S')} erstellt.", at: [ 0, -15 ])
- end
- @prawn_document.bounding_box([0, 0], width: 516) do
- hr
- end
- @prawn_document.bounding_box([0, 766], width: 516) do
- hr
+ # @prawn_document.draw_text("Dokument erstellt am #{Time.current.strftime('%d %B %Y')} um #{Time.current.strftime('%H:%M:%S')}", at: [ 0, -15 ])
end
+ # @prawn_document.bounding_box([0, 0], width: 532) do
+ # hr
+ # end
end
x = params
@@ -105,6 +170,8 @@ module PdfDocuments
end
heading4("Protokollnummer")
text(success_criterion.number)
+ heading4("WCAG")
+ text("#{success_criterion.check.external_number}'", inline_format: true)
move_down(10)
end
end