Closed raycarrick-ed closed 5 years ago
@sjDCC can you verify if this is still an issue? Things seem ok in DMPTool and Roadmap but perhaps an issue for DMPTuuli or others. The PDF footer at some point contained bad characters. I think though that its been resolved by all of the work done over the past year.
Hello, I have this issue on my test server of DMP OPIDoR. I'm running roadmap V1.0.5.
I resolved this issue by adding encoding: 'utf8'
in export method of the plans_controller.rb
Here is my export method :
def export
@plan = Plan.includes(:answers).find(params[:id])
authorize @plan
@show_coversheet = params[:export][:project_details].present?
@show_sections_questions = params[:export][:question_headings].present?
@show_unanswered = params[:export][:unanswered_questions].present?
@public_plan = false
@hash = @plan.as_pdf(@show_coversheet)
@formatting = params[:export][:formatting] || @plan.settings(:export).formatting
file_name = @plan.title.gsub(/ /, "_")
respond_to do |format|
format.html { render layout: false }
format.csv { send_data @plan.as_csv(@show_sections_questions), filename: "#{file_name}.csv" }
format.text { send_data render_to_string(partial: 'shared/export/plan_txt'), filename: "#{file_name}.txt" }
format.docx { render docx: "#{file_name}.docx", content: render_to_string(partial: 'shared/export/plan') }
format.pdf do
render pdf: file_name,
margin: @formatting[:margin],
footer: {
center: _('Created using the %{application_name}. Last modified %{date}') % {application_name: Rails.configuration.branding[:application][:name], date: l(@plan.updated_at.to_date, formats: :short)},
font_size: 8,
spacing: (Integer(@formatting[:margin][:bottom]) / 2) - 4,
right: '[page] of [topage]',
encoding: 'utf8'
}
end
end
end
@benjaminfaure, thanks for confirming that its still an issue and for providing the fix :)
We'll need to add this encoding line to the plans controller and the public templates export
Hi @xsrust @johnpinto1 Can you tell me how to test this one? Is it special characters like umlauts in the footer that had caused issues previously?
@sjDCC Change the Language setting to French (say). Then look at the footer.
I noticed the issue is not an issue on DMP Online (but as @benjaminfaure https://github.com/DMPRoadmap/roadmap/issues/73#issuecomment-388828913 pointed out they were having the issue). So this fix does no harm.
The French specific characters should appear as expected in the footer
All looking good. Closing out
UTF is fine in the body of the pdf but not in the footer. Needs further exploring. Setting the encoding works for the body but not the footer, need to find out where that is getting set.