Issue printing leaflet map and imagery layer using wkhtmltopdf - ruby-on-rails

currently we are working on a web tool using Ruby on Rails and one of their functions is generate a PDF report based in HTML template, that template has a map built with leaflet-0.7.3 and we are using a gem called pdfkit v0.8.2, wkhtmltopdf-binary v0.9.9.3 to generate PDFs, but right now we are facing an issue with that report, when It generates that report it is splitting the map and layers like this:
PDF error
It is supposed to look like this
Expected result
Any suggestions what's going on? or what should we do?
Any help would be great for us! thank you guys

I was facing a similar issue with my HTML template when It was generated, so, I solved it replacing my leaflet stylesheet with the last version, which is
http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css
please, replace your current stylesheet and share me what was your result.

Related

Prawn + WickedPDF: Using Prawn on wkhtmltopdf/WickedPDF generated PDF's

I am working on a Rails project with both WickedPDF and Prawn. I am using WickedPDF to convert some HTML into a PDF and then using Prawn to add content to that PDF.
When I add content to an uploaded PDF (one that I do not create), Prawn is able to add content without any issues. When I create a PDF using WickedPDF, Prawn has issues when it adds content to the the new WickedPDF generated PDF. It adds the content, but the content seems to be scaled down... a lot (it's barely visible). If I open that same PDF from another program (Gimp, LibreDraw, etc.) and export as PDF, the new PDF works on Prawn as well. So I'm positive it has something to do with the formatting of the WickedPDF generated PDF's. I need Prawn to edit the PDF's that are being generated by WickedPDF, or to be able to generate PDF's that are editable by Prawn.
I searched for other solutions, and found Prawnto (no longer exists), PDFKit (gem installers did nothing), PDFcrowd (I can't pay for it), and am now running out of ideas. I'll be looking through the wkhtmltopdf source code to see if I can further understand the underlying issue (I doubt it, don't know enough about PDF file structure/formatting), but would be very happy if someone has encountered this and has any other ideas.
EDIT 1: Same results occur after creating a PDF from wkhtmltopdf. The issue is not with WickedPDF but with the library it uses. Still haven't found the cause.
EDIT 2: Another interesting result. The text is not only getting scaled down. I just multiplied the font size of the text that Prawn is inserting by 128 so I could see the text. Turns out it is also being flipped upside-down (about the x-axis). Something sinister is happening.
I've just started looking into PDF generators. On this forum, one post mentions that he had scaling issues while using gems that relied on wkhtmltopdf, but didn't experience the problems if he called that library directly.
Hope this helps! I'll update this answer once I get started if I have the same issue but am able to resolve it. Cheers!

How to generate PDF forms in Ruby-on-Rails

I would like to generate PDF forms with radio buttons and submit buttons in it by using Ruby on Rails. Does anyone know if there is a Gem that can help with this task?
I've looked into
Prawn,
Wicked PDF, and
PDFKit
but they don't seem to have this feature. Currently I am just using Acrobat Pro to create my PDF and insert the form manually but would like to automate this with a Gem if possible.
Any help would be appreciated, thanks.
EDIT
I just found 2 gems that can help insert radio buttons, check boxes, etc. while generating a PDF in rails: prawn-blank and prawn-forms. It doesn't seem like they are being maintained anymore but they should still be useful. Hope this is useful for others attempting to automate generating interactive PDF files too.
There's also RTeX. That works well if you're willing to translate to LaTeX first. LaTeX is a very good way to store marked-up documents. It just depends on how static each document is.
You can use right-signature to complete your task
https://github.com/rightsignature/rightsignature-api
http://www.gsubbarao.com/2013/03/ruby-rightsignature-api-to-prefill.html

Rails 3, Wicked_pdf not picking up styles, print media type, or separate template

So I've been banging my head on this all day yesterday trying to get PDF rendering to work properly. After trying Prawn and PDFKit, I found that the problem with at least getting it to work at all had to do with wkhtmltopdf on Mac OS 10.7, but now the problem is that it completely ignores any styles I add targeting the pdf, the print media type, and any special templates.
Here is a pastebin of where I'm at now: http://pastebin.com/LW16RYjW
Trying all of these and several others didn't work for me:
http://www.snikt.net/blog/2012/04/26/wicked-pdf/
WickedPDF missing layout
http://akabhilash.wordpress.com/2010/11/27/pdf-generation-with-wicked-pdf-in-rails/
I finally got to this setup:
https://github.com/mileszs/wicked_pdf/issues/87
Not knowing what else to do, I physically copied pdf_helper.rb into my lib/ directory (I don't know why it wasn't there before, or even whether it should've been upon bundling(?))
Can anyone tell me why it doesn't seem to be picking up any of the rendering options in the controller, and how I can get the styles to register without affecting the screen (html) version? Any help would be greatly appreciated. Thanks in advance for your time.
Turn off the middleware, or add the route you are trying to customize in the middleware call as documented in the README.

generate PDF from html document in Rails

anyone knows about some gem or app in rails to create pdf docs from html5 and css3 with some client side programming??
Thanks ;)
Thank you for your responses. I need this for a possible project wich will use jquery for box positioning and then, will export the resultant html to pdf. Roughly, ¿is this possible?
PDFKit and WickedPDF for Client side generation, as suggested by Raphael and jcadam
Flying Saucer with JRuby: http://xhtmlrenderer.java.net
Personally, I got more accomplished by using Prawn PDF generator. It's capabilities are much more extensive, IMHO.
Prawn for Ruby PDF generation: https://github.com/prawnpdf/prawn
WickedPDF: https://github.com/mileszs/wicked_pdf
I'm using it now and rather like it:
"Wicked PDF uses the shell utility wkhtmltopdf to serve a PDF file to a user from HTML. In other words, rather than dealing with a PDF generation DSL of some sort, you simply write an HTML view as you would normally, then let Wicked take care of the hard stuff."
If you need more control, also check out Prawn: https://github.com/prawnpdf/prawn. Though Prawn is not an HTML -> PDF converter and is more useful for creating PDFs from scratch.
I'm using both Prawn and WickedPDF on my current project: WickedPDF to generate 'printable' versions of web pages, and Prawn for generating detailed PDF reports.
I believe the PDFKit gem may be what you're looking for.
https://github.com/pdfkit/PDFKit
There's also IMGKit if you want images instead of PDFs.
https://github.com/csquared/IMGKit

Actual best pdf generator for Rails 3.1

I need a pdf generator for Rails 3.1 application.Which one can you suggest.
I've tried Prawn but it seems me quite not easy for a beginner like me while PdfKit gives me several errors :|
I don't know if it is the best fit for you, but I've heard good things about Wicked PDF/wkhtmltopdf.
I've tried both Wicked Pdf and PdfKit but in Development mode they are extremely slows :( Any other suggestions?
Another (maybe dummy) question: using PdfKit for example, I've seen that it make and open pdf file into web browser,but is there a way to download file into my desktop?

Resources