Convert VSD to PNG using Aspose.Diagram in Java - output is incorrect

Hello Support,

We are using aspose-diagram-19.12.0-jdk16.jar [Java] to convert vsd’s each page into png but it produces incorrect output as attached.

Following is the code to reproduce the issue:-

Diagram visioDiagram1 = new Diagram(filepath);
com.aspose.diagram.ImageSaveOptions options1 = new com.aspose.diagram.ImageSaveOptions(SaveFileFormat.JPEG);
options1.setPageIndex(0);
options1.setPageCount(1);
visioDiagram1.save(imageFile.getAbsolutePath(), options1);

We have also tried with the latest aspose-diagram-20.11-jdk16.jar but the behavior remain same.

preview.png (34.0 KB)
tf16403552.zip (54.9 KB)

@neergupta

The archive you have shared seems to be damaged or corrupted. Would you please share it again so that we can test the scenario in our environment and address it accordingly. Furthermore, please also try to use latest version of the API before sharing the source file.

Hello Support,

sample_vsd.zip (55.0 KB)

Kindy refer the attached zip for vsdx file.
We actually did try with the latest version of the API but the issue still occurs.

Thanks,
Jaspreet

@neergupta

We have logged an issue as DIAGRAMJAVA-50708 in our issue tracking system for the sake of correction. 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.

@neergupta

Could you please provide the output image after highlighting the anomalies inside it? This would help us investigate the issue accordingly.

You can observe it by comparing the actual visio file vs output image. There is lot of blank space to the left, right and bottom of the image.

Can you please let me know when can we expect the fix for this?

@neergupta

We are afraid that the investigation of the ticket is not yet completed and we cannot share any ETA at the moment. However, we will soon inform you once analysis is done and some ETA news is available. Please spare us some time.

We apologize for the inconvenience.

@neergupta

We have again investigated the case and found that the generated image was as per the expectations. There may be a misunderstanding about the image height. Please check the attached screenshot where a arrow ‘2’ is referring to edge which may seem as the height of image. Whereas, it is not and the actual height of the image is at point “1” which is approx. 30px.

J50708.png (38.5 KB)

The issue is that using the above code we get lot of space on left, bottom and right when we generate images for preview of the attached vsdx file. For reference I have attached the vsdx, the image generated and a screenshot depicting the lot of space. The original vsdx file doesnot have so much space around.

Can you please guide how to convert vsdx to image with same spacing as in original vsdx file ?
VsdxToImageSpacesIssue.zip (293.8 KB)

Thanks,
Jaspreet

@neergupta

We used following code snippet with Aspose.Diagram for Java 20.12 and obtained the attached output image from it. We opened this image in MS Paint and did not notice blank space issue.

com.aspose.diagram.Diagram visioDiagram1 = new com.aspose.diagram.Diagram(dataDir + "45.1-0.1.1.vsdx");
com.aspose.diagram.ImageSaveOptions options1 = new com.aspose.diagram.ImageSaveOptions(SaveFileFormat.PNG);
options1.setPageIndex(0);
options1.setPageCount(1);
visioDiagram1.save(dataDir + "output.png", options1);

output.png (28.8 KB)

Could you please make sure to use the latest version and in case issue still persists, please share a sample console application with your environment details so that we can again try to reproduce the issue at our side and share our feedback with you accordingly.

We used the latest version 20.12. The space on left got reduced but still there is lot of space on right and bottom. Screenshots attached of original vsdx that doesnot have much space on right and bottom. But the image produced has too much of space on right and bottom.

Thanksdump.zip (234.3 KB)

@neergupta

We tested the case at our end and did not notice any issue. We used the same code snippet which was shared in our previous response and obtained the attached output image from it which is different than the one provided by you.

output.png (28.8 KB)

Could you please share a sample console application with your environment details so that we can again try to reproduce the issue at our side and share our feedback with you accordingly.

Hi support,

Thanks a lot for your feedback.

I did try the following code in my environment and output remains same with lots of space on right and bottom. We are running following code in eclipse IDE. For reference I am attaching the output and my system information.
We are using amazon corretto to execute the below program [C:\Program Files\amazon-corretto-8.252.09.2-windows-x64-jdk\jdk1.8.0_252]

public static void main(String[] args) throws Exception {
License license = new License();
InputStream licenseStream = new FileInputStream(new File(".\Aspose.Total.Java.lic"));
license.setLicense(licenseStream);

	com.aspose.diagram.Diagram visioDiagram1 = new com.aspose.diagram.Diagram("C:\\Users\\jkaur\\Downloads\\4508.vsdx");
	com.aspose.diagram.ImageSaveOptions options1 = new com.aspose.diagram.ImageSaveOptions(SaveFileFormat.PNG);
	options1.setPageIndex(0);
	options1.setPageCount(1);
	visioDiagram1.save(".\\" + "output1.png", options1);
}

Kindly let me know if you need any more details.

Thanks.
MySystemInformation.JPG (87.0 KB)
output1.png (24.7 KB)

@neergupta

Thanks for sharing further details.

We have updated the ticket information accordingly as we need to investigate it again based upon your recent comments. We will soon inform you as soon as we have some results against our investigation. Please give us some time.

Hi Support,
Is there any update ? Our customer is seeking response.

Thanks,
Jaspreet

@neergupta
Thanks for your patience.
We are still investigating the issue as we have used amazon-corretto to replace oracle JDK and the result was same as before. It is hard to say that issue could be fixed as we are still unable to reproduce it. We have also tried to read the code closely and did not find anything that could cause the issue at your end.

We suggest you generate images with other Visio files having different page sizes (width and height). Please try to get some patterns if the size of the blank edges is same for all cases or it changes according to the page height and width. This would help us in inspecting the code and addressing the issue accordingly.

And you can try to add this line options1.setEnlargePage(false); to see if it works.

Hello,

Thanks for your reply.

In the meanwhile I observed that the PDF output for the problematic visio file is fine whereas image outputs have problem. For reference I have attached new visio problematic doc with its PDF and image outputs.

Additionally I am also attaching the PDF(document.pdf) output of the last time shared visio document.Document.pdf (85.7 KB)

com.aspose.diagram.PdfSaveOptions pdfSaveOptions = new com.aspose.diagram.PdfSaveOptions();
pdfSaveOptions.setSaveForegroundPagesOnly(true);

				outputFile = OfficeResourceUtility.createFile("Document" + UUID.randomUUID(), ".pdf");
				visioDiagram.save(outputFile.getAbsolutePath(), pdfSaveOptions);

Thanks,
JaspreetIncidentManagement.zip (406.6 KB)

@neergupta

Thanks for writing back.

We are checking the provided details and will get back to you shortly.

@neergupta
I am attaching a new version hoping to solve this issue. For I cannot reproduce it locally, I am not sure if the patch is useful. If it does’t work, please give me feedback and I will try more.

Thank you for your understanding and support.
aspose-diagram-21.2.1-java.zip (3.8 MB)