i would like to fill a pdf with data from a form/database (like this https://www.youtube.com/watch?v=SJNCc2GwREA&t=190s but i didn't see any gem for that is this even possible ?
i dont want to create html page and generate a pdf like prawn or wicked PDF.
Do u have any ideas ?
It looks like this gem would do the trick - https://github.com/tcocca/active_pdftk
Let me know if this helps you
Related
I have some predefined Pdf templates which include some dynamic variable like {{firstname}}, {{lastname}}, {{email}} etc. I want to replace these text with dynamic data in pdf without affecting the pdf formatting like font size and color.
I did not find any Ruby Gem to do this. Any help would be appreciated.
I'm new to Ruby on rails. I work on Rails 5. I have a requirement of generating PDF document on click of a button with the details in the database, which I achieved using PRAWN gem. Now there is a requirement that On click of a button I should get an option, in which I should be able to select whether to generate a document in PDF or editable format(DOCX or any other format).
Can we achieve this with PRWAN gem in rails 5?
Please suggest me if there are any other options available.
The gem Prawn works only the pdf.
I belive that all you need is the gem htmltoword
Usage:
require 'htmltoword'
# Configure the location of your custom templates
Htmltoword.config.custom_templates_path = 'some_path'
my_html = '<html><head></head><body><p>Hello</p></body></html>'
document = Htmltoword::Document.create(my_html, word_template_file_name)
file = Htmltoword::Document.create_and_save(my_html, file_path, word_template_file_name)
I'm rendering the PDF data from the output of CK editor (What you see is what you get editor).
The output from that editor would be included with all the HTML, CSS tags in the content. For that I had used 'html_safe' attribute in the show page. But when I try to use the same attribute in the PDF prawn syntax its not working. Can someone please guide me how to get the pure content without all the HTML tags in Prawn PDF?
Thanks in advance.
After a long a Google search I finally got an answer which I wish to share with you.
As html_safe is the action view method in rails, It can not be used in ruby syntax of Prawn pdf.
So for that we can use:
ActionView::Base.full_sanitizer.sanitize(#string)
http://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-strip_tags
I have a page where I use RedCloth to use markdown for the text and images. I want to be able to place a form somewhere in the text by putting the string [Form] and my application does a substitution to replace [Form] with the ruby code to execute a Rails form.
How do I do this? I currently executve the RedCloth-ed text with a "<%=h %>" so I don't know how to substitute a string with the Rails form code?
Thanks!
For example, in my view, I currently display a mp3 player using a gem and its helper:
5 #landing_page
6 #message
7 = mp3_player #landing_page.mp3.url unless #landing_page.mp3_file_name.blank?
8 = #redcloth_landing_page
But I actually want more flexibility in terms of being able to place this mp3 player somewhere within the redcloth document by using a substitution string {mp3}.
I'd like where the {mp3} is placed to be where the mp3 player shows up.
First of all I think i understood your question correctly :D,
If you want to add a form (with html tags) as string and wish to function it as a normal form you should look in to template language like 'liquid' (https://github.com/tobi/liquid/). and it works with 'RedCloth' too
cheers
sameera
Im trying to use prawn to generate a PDF of a log entry, then entries are stored in bbcode ([b]bold[/b] etc...) and is converted to html on display.
Is there any way to display the html in prawn?
It sounds like prawn-format might be what you're looking for, but you'll need to use an older version of prawn if you want to try it out.
You'll probably get the best results if you use a lexical analyser such as 'Syntax' by Jamis Buck (http://syntax.rubyforge.org/) and parse the interesting parts of the HTML chunk and render those parts to PDF.
You can use http://www.princexml.com/ to convert html docs to css, or use the princely plugin to render a pdf as one of the accepted formats of your view. See http://jimneath.org/2009/02/16/creating-pdf-documents-in-ruby-on-rails/
If you are wanting to use prawn directly I don't think there is a way to just use html directly to convert to pdf.