Giving file corrupted error after inserting footer to vss,vsdx or vsd files

@philip.zhou
After inserting footers using Aspose diagram for Java API,when trying to open the vss,vsdx,vsd files, it says “file is corrupted”.

Not able to share the files,because of security reasons.

Thanks
Rama

@Rama_Menon
Thanks for your inquiry.
Please upload the source file and making it private.
Please share your current code that you are using. We will check and assist you accordingly.
Without specific files, it’s difficult for us to locate the exact issues.

@philip.zhou
This is the code snippet used
diagram = new Diagram(fileDir + File.separator + fname);
// Date date = new Date();
// diagram.getHeaderFooter().setFooterCenter(footerText + date + footerText1);
diagram.getHeaderFooter().setFooterCenter(footerText + formattedDate + footerText1);
diagram.getHeaderFooter().setHeaderFooterColor(com.aspose.diagram.Color.getRed());
// Important - to have to change to VSDX,VSD,VSS formats after verification
// diagram.save(fileDir + fname, SaveFileFormat.PDF);
//modified as per Aspose team suggestion
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
// if (fname.endsWith(“.vsdx”) || fname.endsWith(“.VSDX”)) {
// diagram.save(outputStream, SaveFileFormat.VSDX);
// } else {
diagram.save(outputStream, SaveFileFormat.PDF);
// }
///modified on 07/23/2024 to rename file in util itself
int dotlastpos = fname.lastIndexOf(‘.’);
String ProdSuffixedFileName = fname.substring(0, dotlastpos) + “-” + fileSuffix + fname.substring(dotlastpos);

			FileOutputStream fos1 = new FileOutputStream(fileDir + File.separator + ProdSuffixedFileName);

			fos1.write(outputStream.toByteArray());
			fos1.close();
			outputStream.close();

@Rama_Menon
Our own file testing did not find any issues, and the generated VSDX can be opened fine.
Please check the input and output file.
inputoutput.zip (79.8 KB)

Could you please share your sample file (Just need the simplest file that can reproduce the problem) or sent it to my email?
Thanks.

Hi Philip

We are not supposed to share files due to security issues.
Can we do zoom and show the issue related to the visio files or let us know how to go about?

Regards
Rama

@Rama_Menon
Please share some screenshots for the input or output file.
We will check it and try our best to simulate the occurrence of the corrupted issue.
Thanks.

@philip.zhou

Thanks.Tried to share some of the screenshots along with the issues faced in the file attached.

screenshots.docx (245.3 KB)

Rama

@Rama_Menon

Thank you for additional information.
1.Please try our latest java version Aspose Diagram for Java 25.3
Are you saving VSD as VSDX or saving VSDX as VSDX? Are you using Visio 2019 version to open the generated VSDX file?
You can keep only one end dialog box in the file and then run you code,If you still find the issue with latest version, then could you please share the simple file? We will check it soon.

2.Please set the correct license then the arrow marks will be fine.
Please refer to the following document:

Thanks.

@philip.zhou
1.ok will try to use the latest Aspose Diagram for Java 25.3 jar.

The existing code snippet is like this:
It is being saved as PDF.

diagram = new Diagram(fileDir + File.separator + fname);
			//	Date date = new Date();
			//	diagram.getHeaderFooter().setFooterCenter(footerText + date + footerText1);
			diagram.getHeaderFooter().setFooterCenter(footerText + formattedDate + footerText1);
			diagram.getHeaderFooter().setHeaderFooterColor(com.aspose.diagram.Color.getRed()); 
			
			//	diagram.save(fileDir + fname, SaveFileFormat.PDF);
			//modified as per Aspose team suggestion
			ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
			//   if (fname.endsWith(".vsdx") || fname.endsWith(".VSDX")) {
			//	  diagram.save(outputStream, SaveFileFormat.VSDX);
			//   } else {
			diagram.save(outputStream, SaveFileFormat.PDF);						  
			//   }

3)Will check with customer what Visio version they are using to open.
Here was trying to open in Microsoft Visio Viewer.

4)Couldnt understand this point
“You can keep only one end dialog box in the file and then run you code”

5)Thanks for clarifying on the arrow marks issue.

@Rama_Menon
MS Visio cannot open PDF files and will generate an error message.
Please use adobe reader or other PDF Browser to open pdf files.

Modified the code now like this

//modified as per Aspose team suggestion
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
if (fname.endsWith(“.vsdx”) || fname.endsWith(“.VSDX”)) {
diagram.save(outputStream, SaveFileFormat.VSDX);
} else if (fname.endsWith(“.vss”) || fname.endsWith(“.VSS”)) {
diagram.save(outputStream, SaveFileFormat.VSS);

			   } else if (fname.endsWith(".vsd") || fname.endsWith(".VSD")) {
					  diagram.save(outputStream, SaveFileFormat.VSD);
			   }
	//		diagram.save(outputStream, SaveFileFormat.PDF);		

In 25.3 jar, also could see the SaveFileFormat .VSS
Hope this is fine,

@Rama_Menon
Will opening the generated .vss or .vsdx files with MS Visio now display the same error message ?

VSS are stencil files.If there are no specific requirements, it is preferable to generate files in VSD or VSDX format.
Please refer to the following document:

@philip.zhou
The Visio version customer is using is Microsoft Visio Standard 2016.

Will let you know how it goes with the fix.

Thanks
Rama

@Rama_Menon
Thanks for the visio information.
Please let us know Visio opens VSDX or other file formats with the error message?

The vsd file created is still corrupted

@Rama_Menon
Please let us know Visio opens VSD or other file formats with the error message?
Providing a simplified Visio file that replicate the issue would significantly expedite the troubleshooting process.
Thanks.

Shall check and get back on this. Meanwhile can you please provide the latest licensed jars for the below?

  1. aspose-cad-23.4.jar
  2. aspose-cells-24.11.jar
  3. aspose-diagram-25.3.jar
  4. aspose-imaging-23.6-jdk16.jar
  5. aspose-pdf-23.6-jdk17.jar
  6. aspose-slides-23.7-jdk16.jar
  7. aspose-words-24.10-jdk17.jar

@Rama_Menon
Please download the specific product versions from this link of total.

Thanks.