Grails JR report render as HTML - grails

I am using the JasperReports plugin to generate a complex report. It is working fine with pdf file but requirement is that before download the pdf show exact pdf report preview in html format.
I am just trying to use "inline=true" "_format=html".
When It rendering the html there are a big different in PDF and HTML.
The report in html format looks like this:
and in pdf format:
Can you please suggest how I can show exact pdf version in html?

You can use the following line in your controller:
params.IS_USING_IMAGES_TO_ALIGN = false

Related

Convert html to pdf using prawn in ruby on rails

I am working on a Rails project and I need to convert the HTML page to a PDF page but it's writing HTML as it is on a pdf page. PDF page is not showing like a webpage. How can I generate a proper PDF from an HTML file?
Prawn::Document.generate("test.pdf") do
filepath = ${filepath}"file.html"
data = File.read(filepath);
text data
end
prawn is not really an HTML to PDF generator - see https://github.com/prawnpdf/prawn#should-you-use-prawn
You'll need to use another tool, for example wicked_pdf - see https://github.com/mileszs/wicked_pdf#super-advanced-usage
In your case, to quote from the README, you'll need something like
# create a pdf file from a html file without converting it to string
# Path must be absolute path
pdf = WickedPdf.new.pdf_from_html_file('/your/absolute/path/here')

How to save HTML source with filled textareas values DCEF3?

I'm using Delphi Chromium Embedded 3 in a project. In this project I load a local HTML file which contain a HTML form. I would like to save whole HTML source with user-filled values.
Thanks

Configure ckeditor in rails to write in Markdown syntax as opposed to HTML

In one part of my application I am successfully using creditor. It properly takes the text typed in and converts it into html format.
User Types in the content:
And it properly saves the content in html syntax:
In another place in my application I want to again use ckeditor. However: this time I want the content to be converted into Markdown syntax as opposed to HTML syntax. Is this possible? If so, how do you specify that configuration for this one place in the application (as opposed to globally specifying this rule because everywhere else I want ckeditor to continue converting the content into html).
I did look within the ruby gems ckeditor docs. I also looked through the ckeditor documentation on options, however looking through that was a bit overwhelming to me.
Seems like you have to add the markdown addon as it is not part of ckeditor, then follow the documentation.
What I ended up doing was creating a script that converted the database fields in my application that were in markdown syntax into html syntax. I did this with the redcarpet Gem and the rdiscount Gem. With those fields now saved in html syntax instead of markdown syntax, I rendered the text just like I do everywhere else where ckeditor is used.

Best pdf library for rails

I have a requirement to create pdfs with tables. I started it by using prawn. But it was too slow and kept utilizing 100% CPU. Now I moved to wicked_pdf.
This is much faster than prawn but still could be faster. One of my friend recommended TCPDF.
I found rfpdf gem which is TCPDF plugin for rails. Have anyone here used it before? How fast is it?
I also found fpdf. Are they better than wicked_pdf?
You can use 'wicked_pdf' gem. It provides very good support to generate pdf using html code.
https://github.com/mileszs/wicked_pdf
In controller:
def show
#report = Report.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.pdf do
render :pdf => "report",:template => "reports/show"
end
end
end
Create a show.pdf.erb and you can write simple html.
<%= wicked_pdf_stylesheet_link_tag "application" %>
<h1> Report </h1>
<p>
<%= #report.details %>
.................................
</p>
Try PdfKIT, it's awesome and very simple to use. Here is a screencast for it.
You don't state the format of your source material. If you are starting from simple text documents, HTML, or other simple markup formats, then you may wish to have a look at Pandoc. This tool will let you convert simple document types into a number of publication-type formats, including PDF.
Since you have a requirement to produce tables in your PDF files, one easy option would be to create your documents in Markdown format, which includes simple rules for creating tables. See this cheat sheet for an example.
Finally, here is a blog post I read recently that discusses converting Markdown documents to PDF files.
Since you are working with Rails there also exists a lightweight wrapper for Pandoc that might prove useful.
Have a look also on another gem: https://github.com/igorkasyanchuk/rails_pdf
It's using chrome headless to create PDF.

Display html file inside iframe

How to display a HTML file from my system in iframe using rails?
I will explain my issue...
I have a view file that has an iframe which calls an action through <iframe src="controller/action?param=somevalue"></iframe> and the action renders a HTML file based on the params.
The HTML file called has reference to stylesheets and javascripts in the format <script type="text/javascript" src="../common/About.js"></script>
When viewed in browser the HTML file displays correctly with the styles and javascript but when viewed in the application the styling and scripts are not working from the external file. On viewing the source code for the external files i get "Unknown action" error.
What is that i am doing wrong in this?
(reacting to yr last comment): you need to specify css and js files in the iframed html page separately. html in an iframe is rendered completely independent from the surrounding page.
This is not a rails-related question imho.
I found the mistake I made. Its because of routes being not defined properly. When I give relative urls in the html file, the rails views assumes the full path to be some thing like src="controller/common/About.js". As there is no action defined by the name common I was getting the Unknown action error. I have redefined my routes and its working fine now.

Resources