Using Aspose.Words for JasperReports and Java together

Hi again,
as the topic title suggests, we were wondering if it is possible to use both libraries at the same time, the one for JasperReports in order to generate reports from our java servlet, and the Java one to be able to access to document merging and appending methods, which seems to be missing in the JasperReports library.

We tried to put both libraries in the lib/ folder of our tomcat installation, but here is what we get when trying to running them

type
Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
root cause

java.lang.IllegalAccessError: tried to access class com.aspose.words.lr from class com.aspose.words.jasperreports.a.c
com.aspose.words.jasperreports.a.c.(Unknown Source)
com.aspose.words.jasperreports.AWAbstractExporter.exportReport(Unknown Source)
SingleReport.exportReportToBytes(SingleReport.java: 320)
SingleReport.CompileReport(SingleReport.java: 836)
SingleReport.processRequest(SingleReport.java: 124)
SingleReport.doPost(SingleReport.java: 213)

javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.

This occurs even if the servlet does NOT import the Java library at all. Is it possible to fix this, or these library are actually meant to be used separately?
Or else, is there a way for us to merge documents together using only the Aspose.Words for JasperReports library?

Hi,
I have forwarded your inquiry to our Aspose.Words for Java developer. He will take a look at it shortly and then one of us will respond.
Thanks.

As far as I understand, the problem is caused by the following. Aspose.Words for JasperReports is buit on top of Aspose.Words for Java. When using a separate jar of Aspose.Words for Java, you actually end up having duplucate instances of the same classes. In other words, this is a “dll hell” in Java environment.
I may be wrong, but I think there is a way to separate jars in some servlet containers. I can search for more detailed information if you are not sure how to accomplish that, just let me know.
Thanks.

That would be very kind of you, since I must admit that I’ve never used tomcat before and I do not know much about how it handles libraries. Anyway we will be making some experiment with it, hoping to get some good result

Thanks for your help!

Hooray! We got it working!

It was just a matter of putting the two .jar files in different folders.

Now, I have a little question about Aspose.Words for Java capabilities: is it possible to use this class to open a .rtf file and then convert it into a .doc file? Please note that by converting I do not mean just change encoding and extension, but to really obtain a .doc file without all those text areas, but instead a normal flow layout.

So, actually, we are looking for a complete automatic conversion of the document. Perhaps we are asking too much, but still we need to know if it is possible.

Hi

Thanks for your inquiry. If you need just convert format you should use the following code:

Document doc = new Document("in.rtf");
doc.save("out.doc");

But, if I understand you correctly, you need also change formatting of your document. If so, could you please attach sample RTF document and expected output? I will check the documents and provide you more information.
Best regards.

Here I’m attaching an archive containing a .rtf document which shows the kind of documents we are dealing with, and how it is structured. I’m also attaching a .doc version of how your library “converts” it.

What we’d want to obtain is a convertion that not only changes encoding and extension, but that changes the layout as well, from positioned elements to flow layout, to obtain a more editable document. The .rtf document as it is, is quite difficult to modify in fact you’d have to manually move all the positioned elements!

Hi

Thank you for additional information. All things in your document is created using floating shapes, even tables. Therefore, it is extremely difficult to convert this document to flow layout. Unfortunately, I cannot suggest you any way to achieve this.
Best regards.

Yes, right now we use JasperReport as our printing engine, which enables us only to print .rtf documents with the positioned elements, and we are looking for a new print engine which will enable us printing .doc and .docx documents with flow layout, but we need to maintain the “look and feel” of the example document I’ve showed you, perhaps re-designing our report templates.

Would this be possible using the Aspose.Words for Java library? If so, how?

Giving a look through your site, I’ve noticed something about the “mail merge” feature. Could you kindly point me to a good tutorial about this?

Thanks!

Hi

Thanks for your inquiry. You can learn more about mail merge here:
https://docs.aspose.com/words/net/mail-merge-and-reporting/
Best regards.

Ok, thank you.