Skip to content

Commit

Permalink
Fix some settings to generate PDF
Browse files Browse the repository at this point in the history
  • Loading branch information
takahashim committed Apr 24, 2024
1 parent 26e967b commit 79ab1cc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/decidim/exporters/pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ def export
Dir.mktmpdir do |dir|
html_path = File.join(dir, "tmp.html")
File.write(html_path, html)
pdf_path = File.join(dir, "tmp.pdf")
url = URI::File.build([nil, html_path])

browser = Ferrum::Browser.new
browser.go_to(url)
browser.pdf(path: pdf_path, landscape: orientation != "Portrait", printBackground: true)
document = browser.pdf(path: nil,
encoding: :binary,
landscape: orientation != "Portrait",
printBackground: true,
scale: 0.8,
format: :A4)

document = File.read(pdf_path)
ExportData.new(document, "pdf")
end
end
Expand Down

0 comments on commit 79ab1cc

Please sign in to comment.