Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Hains-Git opened this issue Jun 18, 2024 · 2 comments

Comments

@Hains-Git
Copy link

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
Copy link
Author

Hains-Git commented Jun 18, 2024

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

@cesc1989
Copy link

🤣 ha! I also experienced a similar problem and the fix was the same thing. I kept the commas from the previous config block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants