Tuesday 31 March 2015

Tip : Removing Meta data of exported or scheduled or e-mail bursted jasper report : Or Changing the report pdf export meta data for Adobe Reader application

This post will give you the quick information on removing or user given pdf application name for jasper reports when open in applications like "Adobe reader".

Generally when you export the report output and open the same pdf file(s) using applications like "Adobe Reader" you can find the application name of the pdf by going "File-> Properties".

By default  the application name for the exported report in pdf format is : Jasper Reports Library 6.0

Now, the question is how to remove this or supply user name ? ( can be a developer name or email sender name)

I must say thanks to  Carlos ( A community guy) for asking me to explore and work this in Jasper. (I love doing experimenting and find something as like you).

This is as simple as one can do very easily in 2 to 3 steps and explained below( but for the 1st attempt one might get conflicts & here is the helping hand for you).

Software used : Jasper Studio 6.x and Jasper Server 6.x, Postgre SQL for simple report testing.

CASE-1 : With a Name supplied for the report 
Step 1: 
Open the report in studio and go to the properties of report
Outline -> Click on Report Name -> Find the properties of the Reports -> Find for the properties in the list and click on Add properties.

Now, add this property
Property Name: net.sf.jasperreports.export.pdf.metadata.creator
Value : Carlos Natividade

Now save the report and run (publish/schedule/email burst) and export it to pdf.

Test 1 : Exporting from studio and checking in Adobe reader properties (application name)
Test 2 : Exporting from Jasper Server and checking the file from Adobe reader properties (application name)
Test 3 : Scheduling the report in the JasperServer - output of scheduled report format is pdf and test by downloading it and checking the file from Adobe reader properties (application name)
Test 4: Email bursted report in pdf format - download the report and check the file from Adobe reader properties (application name)

In all the cases we get the application name with Carlos Natividade.

For your quick reference find the below sample output opened in "Adobe Reader Application"


CASE-II : Don't want to print any name for exported pdf when open in application like "Adobe"
Repeat the CASE-I procedure but simply ignore the value for the property.
Sample output image :


Looking for similar kind of properties to apply, please refer below reference link and play around with the properties. 

A sample JRXML which runs on postgresql foodmart database: (Looking for ready available JRXML - Copy paste below entire code in a opened Jasper Report and test it)

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.0.1.final using JasperReports Library version 6.0.0  -->
<!-- 2015-03-31T01:45:40 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="&quot;&quot;" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="6d836bdc-d774-45c5-8e2c-5431bdf1f892">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="foodmart_db"/>
<property name="net.sf.jasperreports.export.pdf.metadata.creator" value="Carlos Natividade"/>
<property name="ireport.jasperserver.url" value="http://localhost:8080/jasperserver-pro/"/>
<property name="ireport.jasperserver.user" value="superuser"/>
<property name="ireport.jasperserver.report.resource" value="/Explore/RemovalOfMetaData_files/main_jrxml"/>
<property name="ireport.jasperserver.reportUnit" value="/Explore/RemovalOfMetaData"/>
<queryString language="SQL">
<![CDATA[SELECT * FROM customer LIMIT 10]]>
</queryString>
<field name="customer_id" class="java.lang.Integer"/>
<field name="account_num" class="java.lang.Long"/>
<field name="lname" class="java.lang.String"/>
<field name="fname" class="java.lang.String"/>
<field name="mi" class="java.lang.String"/>
<field name="address1" class="java.lang.String"/>
<field name="address2" class="java.lang.String"/>
<field name="address3" class="java.lang.String"/>
<field name="address4" class="java.lang.String"/>
<field name="city" class="java.lang.String"/>
<field name="state_province" class="java.lang.String"/>
<field name="postal_code" class="java.lang.String"/>
<field name="country" class="java.lang.String"/>
<field name="customer_region_id" class="java.lang.Integer"/>
<field name="phone1" class="java.lang.String"/>
<field name="phone2" class="java.lang.String"/>
<field name="birthdate" class="java.sql.Date"/>
<field name="marital_status" class="java.lang.String"/>
<field name="yearly_income" class="java.lang.String"/>
<field name="gender" class="java.lang.String"/>
<field name="total_children" class="java.lang.Integer"/>
<field name="num_children_at_home" class="java.lang.Integer"/>
<field name="education" class="java.lang.String"/>
<field name="date_accnt_opened" class="java.sql.Date"/>
<field name="member_card" class="java.lang.String"/>
<field name="occupation" class="java.lang.String"/>
<field name="houseowner" class="java.lang.String"/>
<field name="num_cars_owned" class="java.lang.Integer"/>
<field name="fullname" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="28" splitType="Stretch"/>
</title>
<columnHeader>
<band height="33" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="141" height="30" uuid="fee430bb-49ac-4209-8e03-9e4e38b40c0f">
<property name="local_mesure_unity" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
<textFieldExpression><![CDATA["Customer ID"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="141" y="0" width="141" height="30" uuid="35f79e2f-6669-454d-995a-e4697edbabae">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
<textFieldExpression><![CDATA["Account Number"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="282" y="0" width="141" height="30" uuid="ad4be3cf-c3cd-489f-8bef-275cefe87e14">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
<textFieldExpression><![CDATA["Last Name"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="430" y="0" width="124" height="30" uuid="67609fe5-b3bf-48e8-b1de-6e807e5759f2">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
<textFieldExpression><![CDATA["First Name"]]></textFieldExpression>
</textField>
</band>
</columnHeader>
<detail>
<band height="32" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="141" height="30" uuid="40ea0517-5729-4d45-bbca-5ba4b9f727d4"/>
<textFieldExpression><![CDATA[$F{customer_id}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="141" y="0" width="138" height="30" uuid="95c30bfc-3933-4d41-b748-8d1bae7f894a"/>
<textFieldExpression><![CDATA[$F{account_num}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="279" y="0" width="138" height="30" uuid="3bf1e187-5105-41fa-a95b-5abcb66fe4b4"/>
<textFieldExpression><![CDATA[$F{lname}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="417" y="0" width="138" height="30" uuid="17271741-98ff-4e32-ad8a-6792020574de"/>
<textFieldExpression><![CDATA[$F{fname}]]></textFieldExpression>
</textField>
</band>
</detail>

</jasperReport>


Reference:

http://jasperreports.sourceforge.net/config.reference.html#net.sf.jasperreports.export.pdf.metadata.creator

1 comment: