The new Pentaho Reporting 3.8 is the fourth release in a row where parameter played a important role. After ironing out all the easy problems, we are now in a state where we can think about creatively abusing the system.
There is one questions in the support centres that get repeated over and over again.
How do I limit the visible output types for a particular report?
Up until now, there was no sane answer. You either take it all, or you lock the report down to a single output type. But selecting just HTML and PDF, that was impossible.
The desired output for a report is controlled by the “output-target” parameter. The values for this parameter are defined somewhere deep inside the reporting engine. Every output target has its unique identifier, that tells both the type of the export (pageable or table) as well as the actual content type that is generated (text, html, pdf, and so on).
Output-target | Description |
---|---|
table/html;page-mode=stream | HTML as a single page, all report pagebreaks are ignored |
table/html;page-mode=page | HTML as a sequence of physical pages, manual and automatic pagebreaks are active |
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;page-mode=flow | Excel 2007 XLSX Workbook |
table/excel;page-mode=flow | Excel 97 Workbook |
table/csv;page-mode=stream | CSV output |
table/rtf;page-mode=flow | Rich-Text-Format |
pageable/pdf | PDF output |
pageable/text | Plain text |
pageable/xml | Pageable layouted XML |
table/xml | Table-XML output |
pageable/X-AWT-Graphics;image-type=png | A single report page as PNG |
mime-message/text/html | Mime-Email with HTML as body text and all style and images as inline attachments |
Since Pentaho Reporting 3.8, we check whether the current report defines one of the known system parameter. If you define your own representation of such a parameter, we use your definition instead of the built-in ones.
Using that knowledge, it is easy to create a list parameter that defines a subset of the available output types. Drop your selection into a table-datasource, and define the parameter as one of the single-selection list-parameter types.
Server Side Printing
You can also invoke server side printing directly from the parameter UI without having to go through an XAction. Define a boolean parameter by creating a table with the following entries:
ID | Value |
---|---|
false | Do Not Print |
true |
Make sure you set the default value of your parameter to “false” or make false the first selection in your list, or you are likely to trigger printing involuntarily. Save the trees and so on.
If you want to print to a specific printer, you can do so by defining the “printer-name” parameter as well. And with the magic of the scriptable datasource, you can populate it with all known printers:
import javax.print.DocFlavor; import javax.print.PrintService; import javax.print.PrintServiceLookup; import javax.print.attribute.standard.PrinterName; import org.pentaho.reporting.engine.classic.core.modules.misc.tablemodel.TableModelInfo; import org.pentaho.reporting.engine.classic.core.util.TypedTableModel; PrintService[] services = PrintServiceLookup.lookupPrintServices( DocFlavor.SERVICE_FORMATTED.PAGEABLE, null); TypedTableModel tt = new TypedTableModel(); tt.addColumn("ID", String.class); tt.addColumn("Value", String.class); for (int i = 0; i < services.length; i++) { PrintService service = services[i]; PrinterName displayName = service.getAttribute(PrinterName.class); if (displayName != null) { tt.addRow(new Object[]{service.getName(), displayName.getValue()}); } else { tt.addRow(new Object[]{service.getName(), service.getName()}); } } return tt;
Where can this property file can be found?
What properties file? This article does not mention any. If you are seeking the global configuration, then that can be found in the “pentaho/WEB-INF/classes” directory and in “PRD/resources”.
Hi all.
I have an issue on how to limit the output type in pentaho report. After I followed this I cannot see any change. I put same name on everything as the image shows. Is there something I missed? Or any other way to limit the visible output type?
Let me know your idea. Thanks
Are you using 3.8? If not then you wont have much luck with it. Earlier versions did not allow the override.
Hi Thomas,
Thanks for the tip I was able to trim the selection into paged-HTML, excel and PDF.
There was no problem on the first run of the report right after it was published in BI Server 3.8
However, after revisiting the reports the next day, all of them has this “This parameter is mandatory” message in the Output Target Dropdown list.
The Mandatory Field and Validate Field check boxes of this parameters are NOT checked.
Also, I set the auto-submit in PRD to false.
I also inject autoSubmit=false in the RUN tag in plugin.xml.
I hope you can help me with this one.
Environment:
PRD 3.6
BI 3.8
Please file a JIRA case. A blog is not the right place to coordinate bug-hunts 🙂
Nice post. Is there any way to set the content-disposition for a pdf to attachment rather than inline?
Hi, I am using PRD 3.8.1 and I have added Excel 2007 manually for the export drop down,I get report with extension xlsx when download using this Excel 2007 export option.
Problem is, when I schedule and send report in email with export option as Excel 2007. I get attachment without the xlsx and I need to manually rename and need to add xlsx.
Is there any way that I do not have to rename when exporting Excel 2007 while scheduling it?
Thanks
Hi !
Are there any possibility to show (or turn on) a “print button” panel on the server side report viewer?
Like in the Report Designer.
We use Crystal Reports now to print invoices and other printed documents.
We need the same functionality with the Pentaho. There are reports that shows on the screen, THEN printed out. Maybe after some filtering.
Is it possible in Pentaho Reporting ?
Thanks,
Zoltan