Exception occurs when converting VSD to PDF

Hello,

I am working on project to convert .vsd file to pdf. The conversion fails due to below exception:

java.lang.NullPointerException: Cannot invoke “com.aspose.diagram.b.a.d.g5e.l()” because “this.b” is null
at com.aspose.diagram.a.d.x7_.a(Unknown Source)
at com.aspose.diagram.a.d.u9.a(Unknown Source)
at com.aspose.diagram.a.d.o1.a(Unknown Source)
at com.aspose.diagram.a.d.y31.a(Unknown Source)
at com.aspose.diagram.r9s.a(Unknown Source)
at com.aspose.diagram.Diagram.a(Unknown Source)
at com.aspose.diagram.Diagram.save(Unknown Source)

Code I am using is:

final com.aspose.diagram.PdfSaveOptions pdfOptions = new com.aspose.diagram.PdfSaveOptions();
			final WarningCallbackDiagram warningCallbackDiagram = new WarningCallbackDiagram();
			pdfOptions.setWarningCallback(warningCallbackDiagram);

			// Call the diagram constructor to load diagram from a VSD file
			final Diagram diagram = new Diagram(sourceFilePath);
			
			if (targetType == TargetDocFormats.PDF) {
				if (-1 != pdfStandardLvl) {
					pdfOptions.setCompliance(pdfStandardLvl);
				}
				// Save as PDF file format
				pdfOptions.setSaveFormat(SaveFileFormat.PDF);
				diagram.save(outputFilePath, pdfOptions);
				
				LOGGER.debug("VSD Conversion - preview save done");

			} 

Sample vsd file:
VSDConversion.zip (97.5 KB)

@aakanksha76

The NullPointerException you are encountering while converting a VSD file to PDF using Aspose.Diagram may be due to an issue with the VSD file itself or the way it is being loaded. Here are some steps you can take to troubleshoot and potentially resolve the issue:

  1. Check the VSD File: Ensure that the VSD file you are trying to convert is not corrupted. You can try opening it in Microsoft Visio to verify that it displays correctly.

  2. Use a Sample VSD File: If possible, test the conversion with a known good sample VSD file to see if the issue persists. This can help determine if the problem is specific to the file you are using.

  3. Update Aspose.Diagram Library: Make sure you are using the latest version of the Aspose.Diagram library. Sometimes, bugs are fixed in newer releases, and updating may resolve your issue.

  4. Simplify the Code: You can simplify your code to isolate the problem. For example, try removing the warning callback and any additional options to see if the basic conversion works:

    Diagram diagram = new Diagram(sourceFilePath);
    diagram.save(outputFilePath, SaveFileFormat.PDF);
    
  5. Check for Known Issues: Review the release notes for Aspose.Diagram to see if there are any known issues related to VSD to PDF conversion. For instance, there have been reports of various bugs affecting the conversion process, such as misplaced text or incorrect formatting. These issues might be relevant to your case.

  6. Contact Support: If the problem persists after trying the above steps, consider reaching out to Aspose support with details of the issue, including the stack trace and the VSD file you are using. They may provide specific guidance or fixes.

By following these steps, you should be able to identify the cause of the NullPointerException and find a solution to successfully convert your VSD file to PDF.

If you need further assistance, feel free to ask!

Sources:
[1]: ExportToPDF.cs
[2]: ExportToPDF.java

@aakanksha76

Thanks for the template file and codes.
We reproduced the problems you mentioned by converting your template vsd file to Pdf. We found the exception when setting Compliance before saving pdf.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): DIAGRAMJAVA-51256

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

The issues you have found earlier (filed as DIAGRAMJAVA-51256) have been fixed in this update. This message was posted using Bugs notification tool by philip.zhou

Hello,

I am using the latest version 25.2 and still facing the same issue.

The issue is encountered when PdfSaveOptions is used to save the pdf file.
If SaveOptions used instead of PdfSaveOptions then no issue observed.

But, SaveOptions does not have setPdfCompliance method, so we need to use PdfSaveOptions and its throwing exception I mentioned earlier.

@aakanksha76
The latest version 25.3 has been updated.
Please try our latest version Aspose.Diagram for Java v25.3. Aspose.Diagram 25.3 | Visio Diagram Java High Code API

We are sorry for the inconvenience.

We are using Aspose-Total version 25.2 which is latest version available currently of Aspose.Total.

@aakanksha76
Thank you for additional information.
The release of total version 25.3 may need to wait for our teammates to complete by the end of this month.
Thanks.