I need to generate a pdf file and upload it to the AWS upon some action from my controller. I've never done this before with rails, neither created a pdf and then upload it to the aws.
So here is what I'm thinking, how to proceed.
When a action in my controller occurs and it invokes a method a, it will invoke the Job B which is a delayed job who will call the controller method c which has the respond_to and format pdf. And the job will save the .pdf file to the AWS.
The pdf that I'm using needs to be stored on the aws so it can be emailed to a user later. Not sure if this is relevant, just wanted to give more details.
I'm using prawn gem to generate the pdf
Is there a better way to do this, has anyone done something like this before?
http://rubygems.org/gems/wicked_pdf
"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, and let Wicked take care of the hard stuff."
I've done something similar using pdfkit. Essentially you just define your PDF layout in HTML/CSS, and when a user adds the .pdf suffic to a path, it attempts to generate the PDF. It's nice because you don't have to actually store generated PDF files, but they'll always be available if someone needs them.
Related
I need to generate report to pdf file, save on the server, than send the file to the client by email.
I am looking to a gem for exporting pdf file
And I want to know if the file keep all the pdf options (like links and the option to select text copy text etc')
Thanks
You can use wicked_pdf gem to generate PDF from HTML. You can configure the options whatever you want in their advanced usage.
Wicked PDF is what you need. It will export to PDF and keep all links, text and images as a real PDF would, because it generates a real, full fledge PDF.
I am writing a Program in Rub On Rails 4.x and I have to take PDF files with defined fields that can be filled out, fill in data from a form submission(This part is DONE!), and lastly allow the user to modify the saved PDF file on the server and overwrite said PDF after making their modifications.
Like I said I have already gotten the PDF files filled out with what has been submitted in the form through pdftk . What I now need to do is provide a server side editing capability to the said PDF files on server generated from the first step of the process.
I have seen similar posts but none wanting to do the same thing I do. If I am wrong links would be great. Thanks in advance for all your help!
After lots of digging and research here is what I have found to be the facts surrounding this issue and implementing a program to allow embedding the PDF file, editing it, and saving it back to the server. This process would be great however from what I can tell there is nothing out there that really does this for Ruby On Rails. To quote #Nick Veys
Seems like you need to find a Javascript PDF editor you can load your PDF into, allow the user to modify it, and ultimately submit it back to the server. Seems like they exist, here's one for ASP projects
You are correct but still wrong in the sense that yes there is one for ASP projects however that is Microsoft Based, yes I know that it can run on Linux environments through Mono. However to the point it would appear in this instance that a Ruby On Rails specific solution is indeed needed.
The solution that we have come up with is as follows
1. Use a PDF editing package in the linux repositories like PDFtk
2. You then render a page with the PDF embeded on one side and a form representing the live fields in the PDF to take input.
3. Once submitted you use PDFtk to write the values into a new template PDF file and overwrite what was previously stored.
This requires a few additional steps to process the data than I really care for myself. However it is the best solution that our team could come up with, without bleeding the project budget dry for just 1 piece of functionality.
I hope this helps anyone else looking to do the same thing in Ruby On Rails.
I have done something like this using my company's .NET product. It can also be done using its Java version too.
http://www.gnostice.com/nl_article.asp?id=255&t=Save_Form_Submit_Data_Back_To_Original_PDF_Document_In_NET
I need a user to be able edit a pdf template in rails such that a user can customise logo, email signatures, price etc.
I thought prawn looked like a good option but I read that it should now only be used to generate a pdf from scratch.
Any help, suggestions, pointers to tutorials would be really helpful.
Thank you.
The pdf-forms gem can fill out existing pdf files. This has worked well for me for inserting text into a template PDF.
pdftk supports adding images to an existing pdf via multistamp, which is effectively merging two pdfs together (on top of each other). To add an image to an existing pdf, you could use something like prawn to create a pdf with your image, then use pdftk with multistamp to merge that with your filled out pdf:
pdftk filled_out.pdf multistamp logo.pdf output out.pdf
pdf-forms is a thin wrapper on top of pdftk, so it should allow you to pass the multistamp params required. If not, you can add that functionality or shell out to pdftk directly.
Adobe Acrobat Pro is useful for defining your template fields visually in an existing pdf.
I am not sure but try your luck with Wicked pdf.
I'm currently using PRAWN with latest release of rails and I can't figure out how to download multiple files with a single HTTP request. in my controller I have the following code:
Fill PDF with my stuffs...
PDF.render_file "foo.pdf"
send_file("foo.pdf")
And it download correctly the file but - if after that - I put another istance of the same code...it will execute only the last one, foo2
PDF.render_file "foo.pdf"
send_file("foo.pdf")
PDF.render_file "foo.pdf"
send_file("foo2.pdf")
Moreover, If at end...I wish to render another view, I can't do it.
Question is:
How can I download 2 different files in a single action inside controller and, finally, render a view?
You cant unless you zip them and then send back the zip file
You could use pdftk to combine the pdf's on the server, and send ONE pdf.
Other than that, to only way to get multiple file downloads is to have the broswer send multiple AJAX requests to the server, and each one end with send_file.
That would take some JavaScript, and you'd end up with multiple file download dialogs popping up on your screen.
I am looking to be able to open a pdf file (done) and then be able to use the touch screen to sign the pdf and then save it with the modification. From what i have read this is no easy task, and i have no idea where to begin. Any of you know any tutorials or frameworks that will help me with this ?
Also if possible being able to modify fields of a pdf file, on the desktop the pdf can have fields you can click on then type in to fill out the form, without the need to ever print. If this is possible as well that would be perfect.
Thanks.
Maybe libHaru (http://libharu.org/wiki/Main_Page) does what you want, it's worth a try.
Does your starting point have to be a PDF? steipete's suggestion of using a system to create the PDF would work if your app workflow could create the PDF (sans signature) and display it, the user "signs" it in your app, and you create the PDF again this time with the signature embedded. It depends on whether this flow is an option for your app. Often it seems easier if you treat PDF as a final document and produce the PDF in it's final form each time (final meaning that you're not going to try modifying it).