Exception from AWAbstractExporter.exportReport() for large svg images


#1

Hi support,

I am using svg images in JasperReports with following properties:

ImageExpression =net.sf.jasperreports.renderers.BatikRenderer.getInstance(new java.net.URI($F{URL}).toURL())
ScaleImage =Retain Shape

I am using following libraries:
jasperreports-6.5.1
aspose-words-java-17.6.0
aspose-words-jasperreports-17.6.0

For some larger svg images (see attached file) I get following error:
java.lang.IllegalArgumentException: Invalid scanline stride
at java.awt.image.ComponentSampleModel.getBufferSize(ComponentSampleModel.java:274)
at java.awt.image.ComponentSampleModel.verify(ComponentSampleModel.java:252)
at java.awt.image.ComponentSampleModel.<init>(ComponentSampleModel.java:170)
at java.awt.image.PixelInterleavedSampleModel.<init>(PixelInterleavedSampleModel.java:87)
at java.awt.image.PixelInterleavedSampleModel.createCompatibleSampleModel(PixelInterleavedSampleModel.java:144)
at javax.imageio.ImageTypeSpecifier.getSampleModel(ImageTypeSpecifier.java:1039)
at javax.imageio.ImageTypeSpecifier.createBufferedImage(ImageTypeSpecifier.java:1072)
at javax.imageio.ImageReader.getDestination(ImageReader.java:2892)
at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1317)
at com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1614)
at javax.imageio.ImageIO.read(ImageIO.java:1448)
at javax.imageio.ImageIO.read(ImageIO.java:1352)
at net.sf.jasperreports.engine.util.JRJdk14ImageReader.readImage(JRJdk14ImageReader.java:51)
at net.sf.jasperreports.engine.util.JRImageLoader.loadAwtImageFromBytes(JRImageLoader.java:161)
at awjr.awjr6.awjr7.a(Unknown Source)
at awjr.awjr7.awjr9.ary(Unknown Source)
at awjr.awjr7.awjr9.<init>(Unknown Source)
at awjr.awjr7.awjr7.a(Unknown Source)
at awjr.awjr7.awjr1.a(Unknown Source)
at awjr.awjr7.awjr1.a(Unknown Source)
at com.aspose.words.jasperreports.AWAbstractExporter.a(Unknown Source)
at com.aspose.words.jasperreports.AWAbstractExporter.exportReport(Unknown Source)
at com.deron.te.bi.report.AsposeBiReportDocxExporter.export(AsposeBiReportDocxExporter.java:99)

When the report is generated using the jasperreports-6.5.1 exporter without Aspose it works.
I get the error also with the library Aspose.Words.JasperReports-19.1.

Is there some workaround for this issue? Do you have a better solution than the BatikRenderer to include svg images in the report? Do you have utilities to test if some svg file may cause problems?

Many thanks for your help.
Dan

Diagram.zip (20.3 KB)


#2

@dan.albutiu

Please use the latest version of Aspose.Words for JasperReports 19.6 and let us know how it goes on your side. If you still face problem, please ZIP and attach your .jrprint file here for testing. We will then investigate the issue and provide you more information on it.


#3

Hi Tahir,

I get the same error also with Aspose.Words for JasperReports 19.6.
Please find attached the zipped .jrprint file.
The used svg image is attached to the initial post.

Many thanks for your support.
Dan

exportSvg.zip (67.5 KB)


#4

@dan.albutiu

We have exported the shared .jrprint file to DOCX using the latest version of Aspose.Words for JasperReports 19.6 and have not faced the shared exception. We have attached the output DOCX with this post for your kind reference.

aw jasperreports 19.6.zip (326.3 KB)


#5

Hi Tahir,

Maybe you are using other parameters for the exporter…
Can you send me please the code you use to configure the exporter?

When I compare 2 pdf files, fist is exported by JRPdfExporter, with second exported by AWDocxExporter and saved as pdf, i see a great difference in the quality of the large diagrams.
See attached files; it is the same report but the sizes of the generated files are also very different.
In this example i reduced the size of the diagram by removing some objects. In this way i was able to export using the AWDocxExporter.

Is there a way how i can manage the quality of svg images by some Aspose parameters?
What is your recommended way to include svg images in the report? Using the Batik renderer?

Many thanks for your support.
Dan

CompareExporterOutputs.zip (565.2 KB)


#6

@dan.albutiu

We did not use any parameters for exporter.

Please share the complete steps that you are using at your end to generate the PDF file. Please also share the code example (source code without compilation errors) here to reproduce your issue at our end. We will investigate the issue and provide you more information on it.


#7

Hi Tahir,

We are evaluating the possibility to use png instead of svg images in JasperReports.
The initial issue concerning the export of svg images is not relevant any more for .png.
But now we have an issue with the quality of the .png images in .pdf documents.

Here is how it works (See attachment files).

  1. We generate a .png file using our diagram editor. See largeImage.png, the labels on the shapes are visible in good quality using a zoom factor of 500%.
  2. We use that image in the JasperReport.
  3. We use AWDocxExporter to export the JasperReport to Word. See AsposeExport.docx, the labels on the shapes are still visible in good quality at 500%.
  4. We use aspose.words.java to post-process the .docx document which is finally saved as .pdf. See AsposeExport.pdf, the quality of the image is very poor. The labels are not readable any more.
  5. We have used the same steps with svg images and the result was very good but there are problems with large svg files, first with memory usage, second with the reported error.
  6. Please use TestAsposeExporter.java to reproduce this issue. Please copy the file “jrprint.jrprint” to C:\temp\Aspose\ before running.

How can we improve the quality of the images in .pdf? I tried without success to use the SaveOptions.
Is there another way to solve this problem? We are using the Word exporter also for pdf files because we want to use Word code fields in the JasperReport (ex. { PAGE }, TOC, TOF).

Many thanks for your support.
Dan

TestAsposeExporter.zip (2.0 MB)


#8

@dan.albutiu

Thanks for sharing the detail. You are converting the DOCX to PDF using Aspose.Words for Java. Please note that Aspose.Words mimics the behavior of MS Word. Its mean that if you convert your document to PDF using MS Word, you will get the same output. So, it is not a bug. It is expected behavior of Aspose.Words.


#9

Hi Tahir,
Thank you for your fast response.
Does “mimics the behavior of MS Word” mean, Aspose uses a Word library to make the conversion to PDF and there is no chance to get a better quality compared to the Word conversion?
Many thanks,
Dan


#10

@dan.albutiu

Aspose.Words does not use MS Word library. It is totally independent and are not affiliated with, nor authorized, sponsored, or otherwise approved by Microsoft Corporation.

“Mimic the behavior of MS Word” means that if you convert your document to PDF using MS Word, you will get the same output.

Could you please ZIP and attach your PNG file that you are using in your report? We will then provide you more information about your query.


#11

Please find attached an example of a large png file.
The file TestAsposeExporter.zip attached to my post on august 13, contains other files needed to reproduce the behavior.

Best regards
Dan

largeImage.zip (599.4 KB)


#12

@dan.albutiu

You are facing the expected behavior of Aspose.Words. You can test this case by inserting the large size PNG into empty Word document using MS Word and convert it to PDF. You will get the same output for image.


#13

Hi Tahir,
I knew, Word has poor quality for large images, but i hoped that Aspose is better than Word.
This issue is now resolved for me, you can close the ticket.
Thank you!
Best regards,
Dan


#14

@dan.albutiu

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.