mileszs / wicked_pdf

PDF generator (from HTML) plugin for Ruby on Rails
http://www.mileszs.com/wicked-pdf-plugin
MIT License
3.52k stars 640 forks source link

ArgumentError when changing the WickedPdf.config={...} to the new WickedPdf.configure.do |c| ... end #1121

Closed Hains-Git closed 2 weeks ago

Hains-Git commented 2 weeks ago

Issue description

I had an issue, when i used the configure block in my initializer in Rails. WickedPdf.configure do |config| config[:layout] = 'layout_pdf.erb', config[:orientation] = 'Landscape', config[:page_size] = 'A4', config[:dpi] = 300, config[:zoom] = 1, config[:lowquality] = false, config[:disposition] = 'inline', config[:encoding] = 'UTF-8' end

ArgumentError (String, Proc, :default, true, or false, expected for `layout'; you passed ["layout_pdf.erb", "Landscape", "A4", 300, 1, false, "inline", "UTF-8"])

From this line in my controller: format.pdf do render pdf: @filename, template: 'planer/pdfs/pdf.html.erb', formats: [:html] end

But it works when i use the old config block: WickedPdf.config = { layout: 'layout_pdf.erb', orientation: 'Landscape', page_size: 'A4', dpi: 300, zoom: 1, lowquality: false, disposition: 'inline', encoding: 'UTF-8' }

Expected or desired behavior

It should work with both methods, as long config is not removed.

System specifications

wicked_pdf gem version (output of cat Gemfile.lock | grep wicked_pdf): wicked_pdf (2.8.0)

wkhtmltopdf version (output of wkhtmltopdf --version): wkhtmltopdf 0.12.6.1 (with patched qt)

whtmltopdf provider gem and version if one is used: wkhtmltopdf-binary (0.12.6.7)

platform/distribution and version (e.g. Windows 10 / Ubuntu 16.04 / Heroku cedar): Debian GNU/Linux 11 (bullseye)

Hains-Git commented 2 weeks ago

Sorry, forgotten to remove the "," in the new configure block, so it was my fault. It works, when I remove them.