how to visually design reports generated by dossier? - ruby-on-rails-3

I have used dossier to generate reports in my application. Now I want to visually design my reports generated by dossier like charts. Is there any gem available to do that? Can you please any one help me (or) tell me to how to use iReport in rails application.

Dossier currently does not provide any visualizations (though that would be a nice enhancement). I have been using to to power various JS charting libraries using JSON. Any report can be converted to JSON format by adding a ".json" extension to the report url. Generally I have found that I will have to alter the way I write the sequel selects slightly to get the right JSON output, but overall have had good success with this strategy.
Let me know if I can answer any other questions on this.
Thanks!

Related

Getting wrong page numbers in TOC via docx4j-export-fo

I'm using docxj4 for generating Word documents and now I need to generate a table of contents. Since 3.3.0 version docx4j uses plutext conversion service to get page numbers that is inappropriate for me, so I need to use docx4j-export-fo library for that purpose. But it produces the wrong numbering... Seems like it gets the wrong page size or something like this, because all page numbers are lag 1-2 numbers.
I've researched the source code and properties docx4j provides, but for now I didn't succeed.
As per the documentation, the standalone PDF Converter (which you can download from https://converter-eval.plutext.com/ ) exists precisely to provide better accuracy than can be expected from docx4j-export-fo.
export-fo uses XSL FO to layout the document, and because the XSL FO layout model is not a precise match for Word's, there are limits to what can be achieved.
That said, improvements may be possible in individual cases. You'd need to share your docx somewhere for specific feedback.

How to generate Pdf invoice using Apache PDFBox

I have a requirement in my project to generate an invoice with the help of Apache pdfbox api.As of now I could insert images,text in the generated pdf but finding difficulty in generating tables.I couldn't find even a single example template.If anybody has please provide a link.
Note:I don't have to use iText
Thanx in Advance
This question can be a duplicate to How to create Table using Apache PDFBox. But, I found two solutions which are build on Apache PDFBox.
easytable, I used this to create tables, it has some good features like table extends into new page when reaches the bottom of current page. But I found difficulty in adding both text & image into same cell, multi styles texts into same cell. If any of these are your requirements better check for alternatives.
boxable, Not much familiar with this, but heard that it has some nice features like converting csv data into table directly.

Display tabular data. Is there any option other than looping through dataset and generating a table in razor?

In my MVC application, I need to display data in tabular format (no edit, only readonly) in one of the razor view. Some of the columns should be hyperlink, a couple of columns showing image, and rest columns in plain text.
I know one option is to loop through each row in the dataset (model), and build the table. Anyone has any idea if there is any other way of doing it? (without any third-party control)
Any advice on this, much appreciated.
You can use Phil Haack's tabular template in aspx
or my updated version that is done in razor
About the Visual Studio Add Controller and Add View templates
You may also get some ideas from the List.tt template in [Visual Studio Install Directory]\Common7\IDE\ItemTemplates\[CSharp | VisualBasic]\Web\MVC\CodeTemplates\
My article on changing/customizing that
The closest "non-third party" control I can think of is the WebGrid, but even that isn't included in the ASP.NET MVC distribution if I remember correctly (you might want to check though as I'm not 100% sure).
However, using a simple foreach to generate your table isn't a bad way of doing it either, especially if all you need to do is display some data.
Why no third-party control? Personally, I like datatables.net.

Creating RDLC reports dynamically w/o XML editing

Most would suggest using one of the many XML editors to create a customized RDLC XML, according to user selections, and passing that report to Microsoft's Report Viewer object. I currently implement this method in previous version of my code. However, it is messy, long and lacks eloquence to say the least.
Previous research, I can't remember exactly where I saw it, has led me to believe there is a method to create a data-set, dynamically through code, create an adapter to fill the data-set, and then have that dataset.writeXML() to produce a fully functional copy of XML that can be passed to the Microsoft Report Viewer object.
Again to clarify, I do not want to use XML classes to write my report up. I want to build my dataset through code depending on user selection, have the dataset write out the XML and then pass that to the Reporting object.
A lot of the stuff I've found favors ASP.NET for some reason and I have yet to fully verse myself in its workings.
It seems that what I'm trying to do is write out the RDL (Report Definition Language). This RDL is a set of tags that the Microsoft Report Viewer interprets in order to produce a viewable object to the end user. A data-set is an element of that RDL definition so it really can't produce the RDL itself. Kind of like a baby giving birth to a mama. Here are some excellent resources I found that shed insight into the elements of an RDL file.
Here

Generate PDF from structured data

I want to be able to generate a highly graphical (with lots of text content as well) PDF file from data that I might have in a database or xml or any other structured form.
Currently our graphic designer creates these PDF files in Photoshop manually after getting the content as a MS Word Document. But usually, there are more than 20 revisions of the content; small changes here and there, spelling corrections, etc.
The 2 disadvantages are:
1) The graphic designer's time is unnecessarily occupied. The first version is the only one he/she should have to work on.
2) The PDF file becomes the document which now has the final revised content, and the initial content is out of sync with it. So if the initial content needs to be somewhere else (like on a website), we need to recreate it from the PDF file.
Generating the PDF file will help me solve both these problems. Perhaps some way in which the graphic designer creates a "Template" and then puts in tags/holders and maps these tags/holders to the relevant data.
Thanks :-)
There are some tools out there for doing this. XSL-FO is useful. Here is a tutorial for creating a pdf from xml (or xhtml) with cocoon. Also see Apache FOP.
You could format your SQL data as XML and still use the same templates this way.
I use the ReportLab python library for this. It could perhaps solve your problem, but you will need to do some work...
In the past I have written scripts that spit out LaTeX then used texi2pdf to solve this kind of problem.
Take a look at iReport and JasperReports at http://jasperforge.org.
iReport lets you design reports, and then you can either programatically fill it with the JasperReports library (Java), or just use iReport to manually create the report.
I have only used it for tabular data, but I don't think there would be any problem for other types of documents.
You could create a form and populate the entries programmatically using a pdf library like iText (Java).
You could look at doing the workflow in PostScript which is plain text that you can easily compose from fragments. Then you can use any free tool to convert to PDF.
Take a look at Prince XML. This tool allows to generate PDF based on XML or HTML and CSS.
A possible way is to use a template engine, like FreeMarker or StringTemplate: these are often used to generate HTML, but they are flexible enough to output any format, actually.
The problem is to make a PDF template, I suppose. Perhaps you can take a sample output and edit it to replace data with placeholders to be filled by the template engine. Might not be trivial!
Sounds like a job that SQL Server Reporting Services can handle quite easily.
Reporting Services allows you to query the data, define the layout, and export to PDF without any intervention. The PDF output can be distributed via email, stored on a file share, and accessed via a page on the report server.
It can handle XML data sources too.
Another approach to generating a PDF file from data is to use prawn, which is based on ruby. I was very pleasantly surprised by how much functionality is included in prawn. It may take some investment up front but this approach will give you a lot of flexibility.
You can combine CSStoXSLFO with XEP from RenderX for high quality output. With this solution you can merge XML data into an XHTML template, which is decorated with CSS. It can also generate charts with the fantastic JFreeChart library. CSS3 page media features are supported.