Free Support Forum - aspose.com

Jasper to doc and doc to pdf

hi

i have the need to create from a jasper report a word doc (.doc not .docx) and then convert the .doc to pdf… is this possible? And which products would i need?

Thanks
Chris

This message was posted using Email2Forum by msabir.

Hi Chris,

The following example shows typical code needed to export a report to a DOC file using Aspose.Words for JasperReports. More examples can be found in the demo reports included in the product download.

import com.aspose.words.jasperreports.*;

AWDocExporter exporter = new AWDocExporter();

File sourceFile = new File(fileName);

JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".doc");

exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString());

exporter.exportReport();

You can easily convert the doc to pdf format using Aspose.Words.

You need Aspose.Words for JasperReports.


Regards,

Imran Rafique

Hi Chris,

You can download the latest version from following link for testing.

http://www.aspose.com/community/files/67/jasperreports-exporters/aspose.words-for-jasperreports/default.aspx

The component will function as normal except for an evaluation limitation.


Regards,

Imran Rafique

Thank you


i will give it a shot :slight_smile:

Hi


that worked great :slight_smile:

can you give me any hints on how to convert the doc to pdf?

Thanks
Chris

Hi Chris,

Thank you for request. You can convert the doc to pdf format using following code:


// Open document.

Document doc = new Document("C:\\Temp\\in.doc");

// Accept all changes.

doc.acceptAllRevisions();

// Save document to PDF.

doc.saveToPdf("C:\\Temp\\out.pdf");


Regards,

Imran Rafique

awesome thanks


this is really easy to use … liking it a lot …

unfortunately its telling me that it cant find

com.aspose.words.Document


i have the Aspose.words.jdk16.jar in my classpath... do i need anything else?


Chris

Hello

Thanks for your inquiry. You should just add imports like com.aspose.words and a reference to JAR.


import com.aspose.words.*;

import com.aspose.words.DocumentBuilder;


Best regards,

Could there be an error in the latest Aspose.Words package?


i am getting a compilation error

java.lang.IncompatibleClassChangeError


i googled it and it says it might be an issue with the client jar


http://stackoverflow.com/questions/1980452/what-causes-java-lang-incompatibleclasschangeerror


ill try the version before


Chris

Hi

Thanks for your request. The problem might be caused because there are two different versions of Aspose.Words for Jasper Reports. Have you tried to clear caches?

Also, do you use only Aspose.Words for Jasper Reports in your application or you also use Aspose.Words for Java? Maybe there is a conflict between these products. If so, I suppose you can try wrapping one Aspose.Words JAR into your own JAR and expose only methods, which you use. Maybe this could help you to resolve the problem.

Best regards,

i am trying to put both products… aspose.word and aspose words for jasper reports in my project… same thing happens too if i download an earlier version of apsose.words


does that mean i cant use both client jars in the same project?

Chris

Hi Chris,

Thanks for your request. You can try wrapping one Aspose.Words JAR into your own JAR and expose only methods, which you use. Maybe this could help you to resolve the problem.

Best regards,