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

Draw SVG on PDF with pdfkit gem #413

Closed
imtiaz-emu opened this issue Dec 6, 2017 · 3 comments
Closed

Draw SVG on PDF with pdfkit gem #413

imtiaz-emu opened this issue Dec 6, 2017 · 3 comments

Comments

@imtiaz-emu
Copy link

Could you please give me any idea how to do this? I've asked a question on statckoverflow:

https://stackoverflow.com/questions/47671188/draw-svg-on-pdf-with-pdfkit-gem

@spovich
Copy link

spovich commented Dec 28, 2017

@imtiaz-emu I'm having a similar issue. Have you made any progress on this or taken a different approach?

@imtiaz-emu
Copy link
Author

@spovich I switched to wickedpdf gem. Added gem 'wicked_pdf', gem 'wkhtmltopdf-binary-edge', '~> 0.12.4.0' in gemfile. Then installed wkhtmltopdf in server (https://gist.github.com/brunogaspar/bd89079245923c04be6b0f92af431c10).
In controller used:

pdf = WickedPdf.new.pdf_from_string(as_html)
      save_path = Rails.root.join('public', 'yearly_report.pdf')
      File.open(save_path, 'wb') do |file|
        file << pdf
end


private

  attr_reader :results

  def as_html
    render_to_string(template: "reports/generate_pdf.html.erb", layout: false, locals: {results: results})
end

@spovich
Copy link

spovich commented Dec 28, 2017

@imtiaz-emu thank you! I'll try that out!

@serene serene closed this as completed Feb 24, 2019
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

3 participants