Urgent: Unable to render gradient while generating a jpeg/png file from a SVG file

Hi, we are trying to convert an SVG file to a jpeg/png file using JpegDevice/PngDevice, but it seems to be rendering the gradient incorrectly.

We are using this SVG image gradient_svg_image.zip (1.7 KB)

we have used the below code:
//“this.source” is the data of the SVG file in String.

SvgLoadOptions options = new SvgLoadOptions();
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(
new ByteArrayInputStream(this.source.getBytes()), options);

ByteArrayOutputStream imageStream = new ByteArrayOutputStream();
Resolution resolution = new Resolution(this.height.intValue(), this.width.intValue());
JpegDevice jpegDevice = new JpegDevice(750, 472, resolution, this.res.intValue());// resolution,
// this.res.intValue());
jpegDevice.setCropRectangle(new Rectangle(0, 0, 562, 353));
jpegDevice.process(pdfDocument.getPages().get_Item(1), imageStream);
return imageStream.toByteArray();

Please let us know what seems to be the problem, or if there is anything that we can do differently.

@wvlabelmaker

Would you kindly share the missing values in your code snippet e.g. height/width/resolution. We will test the scenario in our environment and address it accordingly.

yes sure, the values are:
this.height and this.width is equal to 120.
and this.res = 90

Please let me know if you require anything else. Thanks again.

@wvlabelmaker

We were able to notice the issue in our environment using following code snippet with Aspose.PDF for Java 20.3.

SvgLoadOptions options = new SvgLoadOptions();
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(dataDir + "gradient_svg_image.svg", options);
com.aspose.pdf.devices.Resolution resolution = new com.aspose.pdf.devices.Resolution(120, 120);
com.aspose.pdf.devices.JpegDevice jpegDevice = new com.aspose.pdf.devices.JpegDevice(750, 472, resolution, 90);
//jpegDevice.setCropRectangle(new Rectangle(0, 0, 562, 353));
jpegDevice.process(pdfDocument.getPages().get_Item(1), dataDir + "output20.3.jpg");

Therefore, we have logged it as PDFJAVA-39280 in our issue tracking system. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hi, is there any work around that you will be able to suggest.

@wvlabelmaker

Regretfully we cannot offer any workaround at the moment as ticket is pending for analysis. We will surely share with you as soon as we have some updates about ticket resolution. Please spare us some time.

We are sorry for the inconvenience.

Hi @asad.ali, can you please update me on the progress of this ticket.

@wvlabelmaker

We are afraid that the issue is not yet resolved. Please note that we resolve issues on first come first serve basis in the normal support model. However, we will surely take care of your concerns while scheduling the issue for investigation and resolution. We will inform you as soon as we have additional updates regarding ticket resolution. Please spare us some time.

We are sorry for the inconvenience.

Hi @asad.ali, just wanted to know if any progress is made on this ticket?

@wvlabelmaker

We regret to share that earlier-logged ticket is not yet resolved. We will certainly inform you as soon as we have some definite updates regarding its fix. We highly appreciate your patience in this matter.

We are sorry for the inconvenience.

@wvlabelmaker

We have further investigated the earlier logged ticket. Imported document from other formats than .pdf should be saved in pdf file or stream to complete processing.

The following code works fine:

SvgLoadOptions options = new SvgLoadOptions();
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(dataDir + "gradient_svg_image.svg", options);
pdfDocument.save(dataDir + "output_temp.pdf");

pdfDocument = new Document(dataDir + "output_temp.pdf");
com.aspose.pdf.devices.Resolution resolution = new com.aspose.pdf.devices.Resolution(120, 120);
com.aspose.pdf.devices.JpegDevice jpegDevice = new com.aspose.pdf.devices.JpegDevice(750, 472, resolution, 90);
//jpegDevice.setCropRectangle(new Rectangle(0, 0, 562, 353));
jpegDevice.process(pdfDocument.getPages().get_Item(1), dataDir + "output"+version+"_reloaded.jpg");