OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
upload a footer image for PDF exports
as-opac3685ed8009
diff --git a/app/controllers/custom_styles_controller.rb b/app/controllers/custom_styles_controller.rbindex 8ae0dbcb94f..58fc19fec48 100644--- a/app/controllers/custom_styles_controller.rb+++ b/app/controllers/custom_styles_controller.rb@@ -36,7 +36,6 @@ class CustomStylesController < ApplicationControllerUNGUARDED_ACTIONS = %i[logo_downloadexport_logo_download- export_cover_downloadfavicon_downloadtouch_icon_download].freeze@@ -108,6 +107,10 @@ class CustomStylesController < ApplicationControllerfile_download(:export_cover_path)end+ def export_footer_download+ file_download(:export_footer_path)+ end+def favicon_downloadfile_download(:favicon_path)end@@ -128,6 +131,10 @@ class CustomStylesController < ApplicationControllerfile_delete(:remove_export_cover)end+ def export_footer_delete+ file_delete(:remove_export_footer)+ end+def favicon_deletefile_delete(:remove_favicon)end@@ -187,6 +194,7 @@ class CustomStylesController < ApplicationController:export_logo, :remove_export_logo,:export_cover, :remove_export_cover,:export_cover_text_color,+ :export_footer, :remove_export_footer,:favicon, :remove_favicon,:touch_icon, :remove_touch_icon)enddiff --git a/app/helpers/custom_styles_helper.rb b/app/helpers/custom_styles_helper.rbindex f3e0716c747..fce70085fef 100644--- a/app/helpers/custom_styles_helper.rb+++ b/app/helpers/custom_styles_helper.rb@@ -29,6 +29,13 @@#++module CustomStylesHelper+ include TabsHelper++ def pdf_tab?+ selected = selected_tab(design_tabs)+ selected && selected[:pdf]+ end+def design_tabs[{@@ -47,7 +54,8 @@ module CustomStylesHelpername: "pdf_export_styles",partial: "custom_styles/pdf_export_styles",path: custom_style_path(tab: :pdf_export_styles),- label: t(:"admin.custom_styles.tab_pdf_export_styles")+ label: t(:"admin.custom_styles.tab_pdf_export_styles"),+ pdf: true}]enddiff --git a/app/models/custom_style.rb b/app/models/custom_style.rbindex e8b76035a4d..6afd6674705 100644--- a/app/models/custom_style.rb+++ b/app/models/custom_style.rb@@ -32,6 +32,7 @@ class CustomStyle < ApplicationRecordmount_uploader :logo, OpenProject::Configuration.file_uploadermount_uploader :export_logo, OpenProject::Configuration.file_uploadermount_uploader :export_cover, OpenProject::Configuration.file_uploader+ mount_uploader :export_footer, OpenProject::Configuration.file_uploadermount_uploader :favicon, OpenProject::Configuration.file_uploadermount_uploader :touch_icon, OpenProject::Configuration.file_uploader@@ -52,7 +53,7 @@ class CustomStyle < ApplicationRecordupdated_at.to_iend- %i(favicon touch_icon export_logo export_cover logo).each do |name|+ %i(favicon touch_icon export_logo export_cover export_footer logo).each do |name|define_method :"#{name}_path" doimage = send(name)diff --git a/app/models/exports/pdf/components/page.rb b/app/models/exports/pdf/components/page.rbindex cad9dca686d..d019f114266 100644--- a/app/models/exports/pdf/components/page.rb+++ b/app/models/exports/pdf/components/page.rb@@ -90,9 +90,42 @@ module Exports::PDF::Components::Pagedef write_footers!pdf.repeat lambda { |pg| header_footer_filter_pages.exclude?(pg) }, dynamic: true dodraw_footer_on_page+ draw_footer_imageendend+ def custom_footer_image+ return unless CustomStyle.current.present? &&+ CustomStyle.current.export_footer.present? && CustomStyle.current.export_footer.local_file.present?++ image_file = CustomStyle.current.export_footer.local_file.path+ content_type = OpenProject::ContentTypeDetector.new(image_file).detect+ return unless pdf_embeddable?(content_type)++ image_file+ end++ def draw_footer_image+ footer_image = custom_footer_image+ return if footer_image.nil?++ height = styles.page_footer[:size] || 0+ return if height <= 0++ image_obj, image_info = pdf.build_image_object(footer_image)+ scale = height / image_info.height.to_f+ width = image_info.width.to_f * scale+ left = pdf.bounds.left - width - height+ top = styles.page_footer_offset + height - 1+ pdf.embed_image image_obj, image_info, {+ at: [left, top],+ height:,+ scale:,+ position: :right,+ vposition: :bottom+ }+ end+def draw_footer_on_pagetop = styles.page_footer_offsettext_style = styles.page_footerdiff --git a/app/views/custom_styles/_pdf_export_styles.html.erb b/app/views/custom_styles/_pdf_export_styles.html.erbindex 7d3fdc168a5..cb527f8cde1 100644--- a/app/views/custom_styles/_pdf_export_styles.html.erb+++ b/app/views/custom_styles/_pdf_export_styles.html.erb@@ -44,7 +44,7 @@ See COPYRIGHT and LICENSE files for more details.<div class="form--field -required"><div class="attachment_field form--field-container -vertical -shrink"><div class="form--file-container">- <%= f.file_field :export_logo, required: true, class: "attachment_choose_file", size: "15" %>+ <%= f.file_field :export_logo, required: true, accept: 'image/png, image/jpg', class: "attachment_choose_file", size: "15" %></div></div><div class="form--field-instructions">@@ -76,7 +76,7 @@ See COPYRIGHT and LICENSE files for more details.<div class="form--field -required"><div class="attachment_field form--field-container -vertical -shrink"><div class="form--file-container">- <%= f.file_field :export_cover, required: true, class: "attachment_choose_file", size: "15" %>+ <%= f.file_field :export_cover, required: true, accept: 'image/png, image/jpg', class: "attachment_choose_file", size: "15" %></div></div><div class="form--field-instructions">@@ -122,3 +122,35 @@ See COPYRIGHT and LICENSE files for more details.</fieldset></section><% end %>+<% if OpenProject::FeatureDecisions.minutes_styling_meeting_pdf_active? %>+<%= form_for @custom_style, url: custom_style_path, html: { multipart: true, class: "form -vertical" } do |f| %>+ <section class="form--section">+ <fieldset class="form--fieldset">+ <legend class="form--fieldset-legend"><%= I18n.t(:label_custom_export_footer) %></legend>++ <% if @custom_style.id && @custom_style.export_footer.present? %>+ <div>+ <%= tag("img", src: custom_style_export_footer_path(digest: @custom_style.digest, filename: @custom_style.export_footer_identifier), class: "custom-export-footer-preview") %>+ <%= link_to t(:button_delete),+ custom_style_export_footer_delete_path,+ method: :delete,+ class: "icon icon-delete confirm-form-submit" %>+ </div>+ <% end %>+ <div class="grid-block">+ <div class="form--field -required">+ <div class="attachment_field form--field-container -vertical -shrink">+ <div class="form--file-container">+ <%= f.file_field :export_footer, required: true, accept: 'image/png, image/jpg', class: "attachment_choose_file", size: "15" %>+ </div>+ </div>+ <div class="form--field-instructions">+ <%= t("text_custom_export_footer_instructions") %>+ </div>+ </div>+ </div>+ <%= styled_button_tag t(@custom_style.export_footer.present? ? :button_replace : :button_upload), class: "button #{@custom_style.export_footer.blank? ? '-with-icon icon-add' : ''}" %>+ </fieldset>+ </section>+<% end %>+<% end %>diff --git a/app/views/custom_styles/show.html.erb b/app/views/custom_styles/show.html.erbindex c4acd4a6312..fd962a4885a 100644--- a/app/views/custom_styles/show.html.erb+++ b/app/views/custom_styles/show.html.erb@@ -34,6 +34,7 @@ See COPYRIGHT and LICENSE files for more details.) do %><%= render(Admin::DesignHeaderComponent.new(tabs: design_tabs)) %><%= error_messages_for "custom_style" %>+ <% unless pdf_tab? %><%= form_tag update_design_themes_path, method: :post, class: "form" do %><section class="form--section"><fieldset class="form--fieldset">@@ -51,6 +52,7 @@ See COPYRIGHT and LICENSE files for more details.</fieldset></section><% end %>+ <% end %><%= render_tabs design_tabs %><% end %>diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 32c7db9d977..660cfd916eb 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -3028,6 +3028,7 @@ en:label_custom_logo: "Custom logo"label_custom_export_logo: "Custom export logo"label_custom_export_cover: "Custom export cover background"+ label_custom_export_footer: "Custom export footer image"label_custom_export_cover_overlay: "Custom export cover background overlay"label_custom_export_cover_text_color: "Text color"label_custom_pdf_export_settings: "Custom PDF export settings"@@ -4382,6 +4383,9 @@ en:text_custom_export_cover_instructions: >This is the image that appears in the background of a cover page in your PDF exports.It needs to be an about 800px width by 500px height sized PNG or JPEG image file.+ text_custom_export_footer_instructions: >+ PDF exports will include a graphical element positioned to the left of the footer.+ This image must be a PNG or JPEG file with approximately 200 pixels in width.text_custom_favicon_instructions: >This is the tiny icon that appears in your browser window/tab next to thepage's title.diff --git a/config/routes.rb b/config/routes.rbindex b6fc9e405a2..3547fed7f65 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -180,6 +180,10 @@ Rails.application.routes.draw doas: "custom_style_export_cover",constraints: { filename: /[^\/]*/ }+ get "custom_style/:digest/export_footer/:filename" => "custom_styles#export_footer_download",+ as: "custom_style_export_footer",+ constraints: { filename: /[^\/]*/ }+get "custom_style/:digest/favicon/:filename" => "custom_styles#favicon_download",as: "custom_style_favicon",constraints: { filename: /[^\/]*/ }@@ -503,6 +507,7 @@ Rails.application.routes.draw dodelete "design/logo" => "custom_styles#logo_delete", as: "custom_style_logo_delete"delete "design/export_logo" => "custom_styles#export_logo_delete", as: "custom_style_export_logo_delete"delete "design/export_cover" => "custom_styles#export_cover_delete", as: "custom_style_export_cover_delete"+ delete "design/export_footer" => "custom_styles#export_footer_delete", as: "custom_style_export_footer_delete"delete "design/favicon" => "custom_styles#favicon_delete", as: "custom_style_favicon_delete"delete "design/touch_icon" => "custom_styles#touch_icon_delete", as: "custom_style_touch_icon_delete"post "design/colors" => "custom_styles#update_colors", as: "update_design_colors"diff --git a/db/migrate/20250806132912_add_export_footer_to_custom_styles.rb b/db/migrate/20250806132912_add_export_footer_to_custom_styles.rbnew file mode 100644index 00000000000..2bc961a67ef--- /dev/null+++ b/db/migrate/20250806132912_add_export_footer_to_custom_styles.rb@@ -0,0 +1,35 @@+# frozen_string_literal: true++#+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++class AddExportFooterToCustomStyles < ActiveRecord::Migration[8.0]+ def change+ add_column :custom_styles, :export_footer, :string, default: nil+ end+enddiff --git a/modules/meeting/app/workers/meetings/pdf/minutes/exporter.rb b/modules/meeting/app/workers/meetings/pdf/minutes/exporter.rbindex f042d453ebc..a4ba4ed3ac2 100644--- a/modules/meeting/app/workers/meetings/pdf/minutes/exporter.rb+++ b/modules/meeting/app/workers/meetings/pdf/minutes/exporter.rb@@ -89,7 +89,6 @@ module Meetings::PDF::Minuteswrite_agendawrite_minutes_headerswrite_minutes_footers- write_footer_logoenddef write_heading(text)@@ -157,14 +156,7 @@ module Meetings::PDF::Minutesdef write_minutes_footerspdf.repeat lambda { |pg| header_footer_filter_pages.exclude?(pg) }, dynamic: true dodraw_minutes_footer_on_page- end- end-- def write_footer_logo- footer_image = File.join(File.dirname(File.expand_path(__FILE__)), "footer.png")- image_obj, image_info = pdf.build_image_object(footer_image)- pdf.repeat lambda { |pg| header_footer_filter_pages.exclude?(pg) } do- pdf.embed_image image_obj, image_info, { at: [-styles.page_margin_left, -23], height: 8 }+ draw_footer_imageendenddiff --git a/modules/meeting/app/workers/meetings/pdf/minutes/footer.png b/modules/meeting/app/workers/meetings/pdf/minutes/footer.pngdeleted file mode 100644index 25cc7ff0c2c..00000000000Binary files a/modules/meeting/app/workers/meetings/pdf/minutes/footer.png and /dev/null differ