Is there any way to set document properties (such as author, title and comment) of docx, xlsx and odt in Jasper Reports from Java? I have a version 3.7.0 of the Jasper Reports.
Asked
Active
Viewed 2,149 times
4
-
I'm afraid that it is impossible. You can do something like this with *JRPdfExporter*. For *PDF* documents you can find info in [Jasper Report - Set Author property in a PDF document](http://stackoverflow.com/q/5552891/876298) post – Alex K Jul 04 '13 at 14:29
-
By the way, you can try to customize *Exporters* by yourself. :) – Alex K Jul 04 '13 at 14:30
-
For docx and co you could always use apache poi and set the properties after you generated the documents with jasper. – Arno Mittelbach Jul 09 '13 at 09:28
2 Answers
2
This code may be useful for you
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperPath + "myReport.jasper", hm, con);
JRPdfExporter exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE, outPath + outFile);
exporter.setParameter(JRPdfExporterParameter.METADATA_AUTHOR, "Adnan");
exporter.setParameter(JRPdfExporterParameter.METADATA_TITLE, "Title");
// ...
exporter.exportReport();

Anand saga
- 1,433
- 11
- 23
0
With jasperreports 6.7.0
final SimplePdfExporterConfiguration config = new SimplePdfExporterConfiguration();
config.setMetadataTitle("ABC");
config.setMetadataAuthor("XYZ");
final JRPdfExporter exporter = new JRPdfExporter();
exporter.setConfiguration(config);
WORD
SimpleDocxExporterConfiguration config= new SimpleDocxExporterConfiguration();
config.setMetadataTitle("ABC");
config.setMetadataAuthor("XYZ");
final JRDocxExporter exporter = new JRDocxExporter();
exporter.setConfiguration(config);
EXCEL
final SimpleXlsxExporterConfiguration config= new SimpleXlsxExporterConfiguration();
config.setMetadataAuthor("ABC");
config.setMetadataTitle("XYZ");
final JRXlsxExporter exporter = new JRXlsxExporter();
exporter.setConfiguration(config);

RVL
- 1
- 1
- 1