The following is a very very simplified version of the actual code in my application; I was able to isolate the problem to this code and the attached vsdx file:
using (MemoryStream msSource = new MemoryStream(System.IO.File.ReadAllBytes(“c:\test.vsdx”)))
{
Aspose.Diagram.Diagram vDoc = new Aspose.Diagram.Diagram(msSource);
using (MemoryStream msTarget1 = new MemoryStream())
{
vDoc.Save(msTarget1, Aspose.Diagram.SaveFileFormat.VSDX);
using (MemoryStream msTarget2 = new MemoryStream(msTarget1.ToArray()))
{
Aspose.Diagram.Diagram vDoc2 = new Diagram.Diagram(msTarget2);
vDoc2.Save(“c:\test.pdf”, Diagram.SaveFileFormat.PDF);
}
}
}
I’m getting the following exception on the last line (save as pdf):
System.ArgumentNullException was unhandled
HResult=-2147467261
Message=Key cannot be null.
Parameter name: key
Source=mscorlib
ParamName=key
StackTrace:
at System.Collections.Hashtable.get_Item(Object key)
at (Object , Object )
at ..(String familyName, FontStyle style)
at ..GetFont(String familyName, FontStyle style)
at ..GetFont(String familyName, FontStyle style)
at ..(String familyName, FontStyle style, String altFamilyName)
at ..(String familyName, Single sizePoints, FontStyle style, String altFamilyName)
at ..(Char charNode, FontCollection fonts, Single fontSize, String defaultFont)
at ..(Int32 charIX)
at .…ctor( drwShape, Single resolution, Double scaleRate, String defaultFontName)
at ..( drwShape, canvas)
at ..a( canvas, drwShape)
at ..(Page page, apsPage)
at ..a(Page page)
at ..( apsRenderer, Page page)
at ..Save(Stream stream, PdfSaveOptions pdfOptions, Diagram diagram)
at Aspose.Diagram.Diagram.Save(Stream stream, SaveOptions options)
at Aspose.Diagram.Diagram.Save(String filename, SaveFileFormat format)
Of course, my code does a lot of other things in between, but as I stated, I was able to isolate the problem to this code and the file attached.
Please help me, my client has a lot of Visio files and this problem is showing up frequently.
Javier Pelaez