DynamicJasper and Asian characters - jasper-reports

My PDF generated by DynamicJasper now looking exactly as it's supposed to, I am facing only one more problem: Asian characters are not displayed at all in the resulting PDF. Any other characters work fine. I can verify in the debugger that the Strings are properly placed in the JRDataSource, and Jasper does in fact generate lines for them in the report, but the text itself is completely missing.
Are there some additional encoding settings to be considered when using DynamicJasper with Asian text elements?
Thanks for any advice and best regards

Okay, so this is what fixed the issue, step by step:
1.) Add the Arial Unicode MS font extension JAR to your classpath (or any other equivalent unicode font). An "official" one can be found here, I ended up using this one, however. If you're using maven, you can use the following mvn command line and POM entry to add the file to your classpath:
mvn install:install-file -Dfile=DynamicJasper-arial-unicode-fonts-1.0.jar -DgroupId=ar.com.fdvs -DartifactId=DynamicJasper-arial-unicode-fonts -Dversion=1.0 -Dpackaging=jar
<dependency>
<groupId>ar.com.fdvs</groupId>
<artifactId>DynamicJasper-arial-unicode-fonts</artifactId>
<version>1.0</version>
</dependency>
2.) Add, if not already present, spring-core and spring-beans to the project:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>3.2.2.RELEASE</version>
</dependency>
3.) Enable "Identity-H" Jasper PDF encoding:
static {
JRProperties.setProperty("net.sf.jasperreports.default.pdf.encoding", "Identity-H");
}
4.) Configure Arial Unicode MS as your DynamicJasper font (e.g. for rows):
// ...
final DynamicReportBuilder dynamicReportBuilder = new DynamicReportBuilder();
final Style style = new Style();
style.setFont(new Font(Font.MEDIUM, "Arial Unicode MS", false));
dynamicReportBuilder.setDefaultStyles(null, null, null, style);
// ...
That was some annoying crap :-/ ...

you may have to configure jasper report exporter to embed special fonts on the pdf file. also check ck the pdf character encoding

Related

How do I update Itext7 to version 7.1.1

This seems like it should be simple but I cannot find anything on how to upgrade to newer versions of itext7. I am using an Eclipse maven project with itext7 version 7.0.4 and would like to update to 7.1.1. However, I can find nothing that tells me how to do that. Neither the Eclipse update menu or the Maven menu has an option to update itext7. Can someone point me to the documentation on how to do an update? TIA.
After answer:
I am not getting the libraries but instead getting conflicts:
I can't seem to post my pom.xml using code tags (I guess the formatter has a problem with XML code because of the <>) but I will include it if someone tells me how. I've uploaded the pom file to DropBox:
pom.xml
(Turning #mkl's and #amedee's comments into an answer)
In your project there is a file pom.xml which contains the Maven project definition. In there is a dependencies section with entries for the iText artifacts (among others). The version is therein. Well, it could also be in a separate dependencies management section or in a parent pom.xml referenced in your file.
As soon as you update the POM file, you can update the Eclipse project configuration in your Eclipse Maven menu. That will, if necessary, automatically download the jar artifacts. If your Eclipse Maven integration is properly configured, that is, and if your computer has proper internet connectivity.
Old versions will remain in your local repository but won't be in the class path anymore.
Also check out our getting started guide. Which contains an example POM snippet.
https://developers.itextpdf.com/itext7/download-and-install-information/Java
If you put your iText version number in POM properties, then you only have to update the value once when you want to upgrade. Like this:
<properties>
<itext.version>7.1.1</itext.version>
</properties>
and then
<dependencies>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>kernel</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>io</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>layout</artifactId>
<version>${itext.version}</version>
</dependency>
...
</dependencies>

Replace JasperReport iText 2.1.7 with latest iText 7.0.1

We are using JasperReport 6.1.0 which has a dependency to com.lowagie:itext:jar:2.1.7.js2. It looks like iText 2.1.7 has IP issue, and iText is asking all users to use the latest version which requires a commercial license. So we would like to buy iText license. Now iText latest version is 7.0.1. I tried did below steps to replace JasperReport's iText 2.1.7 with latest iText 7.0.1:
1. Exclude default itext 2.1.7 dependency in pom.xml
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.1.0</version>
<exclusions>
<exclusion>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
</exclusion>
...
2. Add new iText jars in pom.xml
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>barcodes</artifactId>
<version>7.0.1</version>
<!-- barcodes depends on kernel -->
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>font-asian</artifactId>
<version>7.0.1</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>forms</artifactId>
<version>7.0.1</version>
<!-- forms depends on kernel and layout -->
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>hyph</artifactId>
<version>7.0.1</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>io</artifactId>
<version>7.0.1</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>kernel</artifactId>
<version>7.0.1</version>
<!-- kernel depends on io -->
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>layout</artifactId>
<version>7.0.1</version>
<!-- layout depends on kernel -->
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>pdfa</artifactId>
<version>7.0.1</version>
<!-- pdfa depends on kernel -->
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>sign</artifactId>
<version>7.0.1</version>
<!-- sign depends on kernel, layout and forms -->
</dependency>
3. Run mvn and test report function, I got below error:
2016-11-17 14:43:36,520 ERROR [c.i.c.d.DeferredOperationManager] [ Thread-49] Exception on Deferred Operation. Operation UUID: 2a647922-d6d0-450d-9b2d-4d97638ba03f. UI Error key:d9a16093-be20-4278-9f8b-93120c0a2231 - Error: java.lang.NoClassDefFoundError: com/lowagie/text/SplitCharacter
It looks like JasperReport is trying to find old iText classes which namespace is "com.lowagie...".
I tried to unzip the new iText 7.0.1 jar, the classes are in package "com.itextpdf...".
How can I make the JasperReport call the new iText jar?
You can not replace iText 2.1.7 with iText 7 because the differences between the two versions are too big. We do know of some people who moved to using iText 5 with JasperReports. That requires a number of changes to JasperReports such as changing the package names from com.lowagie to com.itextpdf (*) and changing references to com.lowagie.text.Color to com.itextpdf.text.BaseColor.
At iText, we noticed that we were hitting the ceiling with iText 5. For instance: we store text using char which means that each character is stored using only 2 bytes. That wasn't sufficient if we wanted to support Hindi. We had to rewrite the complete font layer if we wanted to add support for Indic languages to iText. "Replacing the font layer" in iText 5 would have been really difficult since the font layer is the foundation on which all the rest of the code is built. Hence our decision to rewrite the complete API.
You can watch a video that goes into more detail regarding this decision here: Devoxx 2016: "Oops I broke my API"
However: the biggest problem with replacing iText 2.1.7 with iText 7, is that JasperReports depends on PdfGraphics2D and we haven't ported that part to iText 7 (yet). We might even decide not to port that part ever, because it is impossible to create PDF/UA if you choose to use PdfGraphics2D (and PDF/UA is getting more and more important).
(*) In 2009, I decided to remove my name from the package names. When I first released iText, I only owned the lowagie.com domain, and I used com.lowagie packages for all the Java code I wrote. I didn't expect iText to become such a success. When everyone started to use iText, everyone started to ask me questions personally. I didn't have a life anymore. Hence I created a company, we professionalized iText and replacing com.lowagie with the more neutral com.itextpdf was one of those professionalizations.

How to make gwt material table

I got gwt material table from github https://github.com/GwtMaterialDesign/gwt-material-table
But i am not getting any jar of it to inherit. So if any one who got the jar please reply me.
If jar is not there then what we have to do either using the class from git or any other way.
After having research on it i have try to make plugin by taking all file from git but $this() is creating a problem.
I can't able figure out what is use of $this() in gwt. I have also include the file gwt material query but then also the method $this() is undefined for the type AbstractDataTable error is comming.
You will need to add this to your pom.xml
<!-- For GWT Material JQuery -->
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material-jquery</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- For GWT Material Table -->
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material-table</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
I'm not sure whether I understand your problem correctly. If it's about resolving dependency, you should be able simply to get it from Maven. As you see from Github, this is a Snapshot. It means you need to add proper repository to your pom.xml file. Please see the section "repositories" and details related to "snapshots-repo" provided there: https://github.com/GwtMaterialDesign/gwt-material-table/blob/master/pom.xml .
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material-table</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
Hope you'll find it helpful.

GXT 3.1 : Neptune Theme not applied

i'm currently using GXT 3.1.1 and i'm trying to change the graphic theme to use the Neptune theme display.
To do so, i added the following lines in my pom.xml
<dependency>
<groupId>com.sencha.gxt</groupId>
<artifactId>gxt</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>com.sencha.gxt</groupId>
<artifactId>gxt-theme-neptune</artifactId>
<version>3.1.1</version>
</dependency>
I also added the following code in my .gwt.xml file
<inherits name='com.sencha.gxt.theme.neptune.Theme' />
The jars are added to my lib folder but when i deploy my war, the only display change I notice is the font change (which is now bold and bigger) in my Standard theme (btw, yes i did comment the row about the standard theme in my .gwt.xml file)
Has anyone experienced the same phenomenon?
Thx
Edit
I'm using java 1.6. Does this version enable the use of the Neptune theme?
Try to add in your .gwt.xml
<inherits name="com.sencha.gxt.themebuilder.base.ThemeBase" />

PDFStamper fails on several PDF files (itext 5.5.1)

I'm trying to fill PDF forms with data and got PDFStamper (itext version 5.5.1) to work with several PDF files, but on some it always fails. Sample code:
PdfReader reader = new PdfReader(new FileInputStream("C:/Temp/source.pdf"));
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("C:/Temp/temp.pdf"));
stamper.close();
Two different error messages until now, first one:
Exception in thread "main" java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V
at com.itextpdf.xmp.impl.XMPMetaParser.createDocumentBuilderFactory(XMPMetaParser.java:423)
at com.itextpdf.xmp.impl.XMPMetaParser.<clinit>(XMPMetaParser.java:71)
at com.itextpdf.xmp.XMPMetaFactory.parseFromBuffer(XMPMetaFactory.java:167)
at com.itextpdf.xmp.XMPMetaFactory.parseFromBuffer(XMPMetaFactory.java:153)
at com.itextpdf.text.pdf.PdfStamperImp.close(PdfStamperImp.java:337)
at com.itextpdf.text.pdf.PdfStamper.close(PdfStamper.java:208)
Second:
java.lang.reflect.InvocationTargetException
[...]
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.itextpdf.xmp.impl.XMPMetaParser
at com.itextpdf.xmp.XMPMetaFactory.parseFromBuffer(XMPMetaFactory.java:167)
at com.itextpdf.xmp.XMPMetaFactory.parseFromBuffer(XMPMetaFactory.java:153)
at com.itextpdf.text.pdf.PdfStamperImp.close(PdfStamperImp.java:337)
at com.itextpdf.text.pdf.PdfStamper.close(PdfStamper.java:208)
The error messages vary, maybe because of different environments (full application vs. test class, but both using itext-5.5.1.jar).
One of the working PDF form was created using OpenOffice Writer, which produced a version 1.4 (Acrobat 5.x) document. The failing PDF form was created using Acrobat Distiller 7.0.5, pdf version 1.6 (Acrobat 7.x). I already tried to convert it down to version 1.4/5.x without luck.
Any ideas?
We had the same problem in our project, where we used FOP for generating PDF and iText for PDF signing.
FOP has a dependency on the xercesImpl:xerces jar. This jar is important for JRE <= 1.4 but it isn't needed in the JRE>1.4 and works without it (more information on JDK 1.6 and Xerces?).
Ps: Check that you do not have the xerces library on classpath, if so remove it.
I had the same problem (with xerces), I could fix it by adding an exclusion in my dependency:
<dependency>
<groupId>net.sf.barcode4j</groupId>
<artifactId>barcode4j-fop-ext-complete</artifactId>
<version>2.0</version>
<type>jar</type>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</dependency>