We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Unable to SaveAs pdf or any other non visio format

Good morning,

I am attempting to open the attached vdx file and then save it as PDF, however if I try and save this file as anything other than a visio format, i get an error stating that the “Input string was not in a correct format” .

for my test I used the following code:

Diagram diagram = new Diagram(FilePath);
diagram.Save(TempFilePath +".vdx", SaveFileFormat.VDX); //This works

diagram.Save(TempFilePath +".pdf", SaveFileFormat.PDF); //This does not work

The PDF File is created, but has a size of 0, and does not open.

Some info… This file has bitmap images, dynamic connections, and Rectangle shapes that have been added using aspose.diagram. Each shape has also been given an extensive list of props. None of this appears related since the save as VDX works.




Hi Charles,


Thank you for posting problematic VDX drawing in this forum thread. We managed to replicate the error message said. We have logged this issue under ticket id DIAGRAMNET-50236 in our issue tracking system. Your request has also been linked to this issue id. We’ll notify you once it is fixed. We’re sorry for the inconvenience you faced.

[quote user=“imran.rafique”]Hi Charles,


Thank you for posting problematic VDX drawing in this forum thread. We managed to replicate the error message said. We have logged this issue under ticket id DIAGRAMNET-50236 in our issue tracking system. Your request has also been linked to this issue id. We’ll notify you once it is fixed. We’re sorry for the inconvenience you faced.

[/quote]
Are you aware of which object within that visio file is preventing me from saving so that I can delete them?

Hi Charles,


Thank you for your inquiry. We need to investigate it. This issue has just been reported. Please spare us a little time. We’ll let you know once an update is available.

This has since been solved.


For whatever reason it did not like me setting the line color inside a loop of a shape I inserted using Aspose. Moved where I set the property, and all works fine.
No idea why it was an issue, I just went line by line commenting stuff out until I narrowed it down.

Hi Charles,


It’s nice to hear from you that you managed it. We have a good news for you that the issue DIAGRAMNET-50236 has now been resolved. If there is no issue in the QA phase, then its fix will be included in the next version of Aspose.Diagram for .NET 4.5.0. Its release date is not final yet. We’ll inform you via this forum thread as soon as the new release is published.

imran.rafique:
Hi Charles,

It's nice to hear from you that you managed it. We have a good news for you that the issue DIAGRAMNET-50236 has now been resolved. If there is no issue in the QA phase, then its fix will be included in the next version of Aspose.Diagram for .NET 4.5.0. Its release date is not final yet. We'll inform you via this forum thread as soon as the new release is published.

What exactly was the bug you fixed and are testing? My error was within my code. I forgot the # symbol when beginning the color value when setting the color.



I have found another, similar bug though.

I am unable to save as PDF if a shape has more than one Chars set
Ex.
shape.Text.Value.Add(new Cp(0));
shape.Text.Value.Add(new Txt("Test0");
shape.Text.Value.Add(new Cp(1));
shape.Text.Value.Add(new Txt("Test1");
shape.Chars.Add(new Aspose.Diagram.Char());
shape.Chars.Add(new Aspose.Diagram.Char());
shape.Chars[0].Color.Value = "#FF0000";
shape.Chars[1].Color.Value = "#00FF00";


When this portion of code is added to my program, the output displays as expected in Visio Viewer, Test0 is Red, and Test1 is Green.

However if I try to save as PDF, I get an error stating "Object reference not set to an instance of an object"


Is there a workaround for this?


EDIT: Basically, this exact example does not work when saving as pdf
http://www.aspose.com/docs/display/diagramnet/Apply+Different+Style+on+the+Each+Text+Value+of+a+Shape
Hi Charles,
imran.rafique:
It's nice to hear from you that you managed it. We have a good news for you that the issue DIAGRAMNET-50236 has now been resolved. If there is no issue in the QA phase, then its fix will be included in the next version of Aspose.Diagram for .NET 4.5.0. Its release date is not final yet. We'll inform you via this forum thread as soon as the new release is published.
ctenc001:
What exactly was the bug you fixed and are testing? My error was within my code. I forgot the # symbol when beginning the color value when setting the color.
We'll now detect color string without '#'. We hope, this helps.
ctenc001:
I am unable to save as PDF if a shape has more than one Chars set
Ex.
shape.Text.Value.Add(new Cp(0));
shape.Text.Value.Add(new Txt("Test0");
shape.Text.Value.Add(new Cp(1));
shape.Text.Value.Add(new Txt("Test1");
shape.Chars.Add(new Aspose.Diagram.Char());
shape.Chars.Add(new Aspose.Diagram.Char());
shape.Chars[0].Color.Value = "#FF0000";
shape.Chars[1].Color.Value = "#00FF00";

However if I try to save as PDF, I get an error stating "Object reference not set to an instance of an object"

EDIT: Basically, this exact example does not work when saving as pdf
http://www.aspose.com/docs/display/diagramnet/Apply+Different+Style+on+the+Each+Text+Value+of+a+Shape
The documented sample code works perfectly on our side. We can save it in PDF format too. Please share problematic Visio drawing and source code in this forum thread. We'll check and guide you appropriately.

The problematic Visio drawing is the same one that is in the OP.

I am attempting to replace the text that is currently their (ie. “Test bone 9 + 10/10/2014”) with a new string of text. I do this with the following loop:




foreach (Shape shape in vdxDiagram.Pages[0].Shapes)
{
foreach (Shape bone in shape.Shapes)
{
if (bone.Text.Value.Text.ToString().Contains(“Test”)) //finds shape with the text I am replacing for this example
{
bone.Chars.Clear();
bone.Text.Value.Clear();
bone.Text.Value.Add(new Cp(0));
bone.Chars.Add(new Apose.Diagram.Char());
bone.Text.Value.Add(new Txt("Color 1 "));

bone.Text.Value.Add(new Cp(1));
bone.Chars.Add(new Apose.Diagram.Char());
bone.Text.Value.Add(new Txt("Color 2 "));


bone.Text.Value.Add(new Cp(2));
bone.Chars.Add(new Apose.Diagram.Char());
bone.Text.Value.Add(new Txt(“Color 3”));

bone.Chars[0].Style.Value = StyleValue.Bold;
bone.Chars[1].Style.Value = StyleValue.Bold;
bone.Chars[2].Style.Value = StyleValue.Bold;
bone.Chars[0].Color.Value = “#0000FF”;
bone.Chars[1].Color.Value = “#00FF00”;
bone.Chars[2].Color.Value = “#FF0000”;
bone.Chars[0].IX = 0; //Unsure what this does but seems necessary?
bone.Chars[1].IX = 1;
bone.Chars[2].IX = 2;
}
}
}




This code works for if I am saving as any visio file format such as vdx. however I error out as stated above if I save as any nonvisio format such as PDF.

Furthermore, if I remove Chars[1] and Chars[2] so that I only have 1 Chars[], it will save as PDF. But I can not achieve the formatting that I require without multiple Chars unless you have another way of coloring individual words within the shape different colors?

Hi Charles,


Thank you for posting the details. We’re working over your inquiry and will get back to you soon.

Hi Charles,


Thank you for being patient. We’re sorry to share with you, we could not reproduce the error message said. You have shared in your earlier post that you removed setting line color option inside the loop. Please provide this modified Visio drawing in this forum thread. We’ll take a closer look and guide you accordingly.

Attached is the exact template that I am using today as well as a simplified, and tested to still have this problem, source code for your review.


We are using aspose.diagram 4.4.0

In the source, if you comment out the save as PDF line, it works and exports to VDX only. If you comment out all references to Chars[1] it works and exports to VDX and PDF successfully. If all code remains the same it fails on the line save as PDF.

Hi Charles,

Thank you for posting sample code and Visio drawing. We have tested your scenario against the latest build of Aspose.Diagram for .NET 4.4.0. We’re afraid because we could not reproduce the error message said. We have cleaned your sample code as follows:

C#

string TempFilepath = @“C:\Ad\test269\Fishbone_Major TYCOM AVAIL w C4I_template.vdx”;
Diagram vdxDiagram = new Diagram(TempFilepath);
foreach (Aspose.Diagram.Shape shape in vdxDiagram.Pages[0].Shapes) //remove dualbone colors that break pdf conversion
{
shape.Text.Value.Clear();
shape.Chars.Clear();
foreach (Shape dualBone in shape.Shapes)
{
if (dualBone.Text.Value.Text.ToString() != “”)
{
dualBone.Text.Value.Clear();
dualBone.Chars.Clear();

dualBone.Text.Value.Add(new Cp(0));
dualBone.Text.Value.Add(new Txt(“Test1\n”)); //add date + name to shape Text.
dualBone.Text.Value.Add(new Cp(1));
dualBone.Text.Value.Add(new Txt(“Test2”));
dualBone.Chars.Add(new Aspose.Diagram.Char());
dualBone.Chars.Add(new Aspose.Diagram.Char());

dualBone.Chars[0].IX = 0;
dualBone.Chars[0].Style.Value = StyleValue.Bold;
dualBone.Chars[1].IX = 1;
dualBone.Chars[1].Style.Value = StyleValue.Italic;
}
}
}
[//vdxDiagram.Save](https://vdxdiagram.save/)(@“c:\ad\test269\Output.vdx”, SaveFileFormat.VDX); //saves visio so that visio viewer can open it.
vdxDiagram.Save(@“c:\ad\test269\Output.pdf”, SaveFileFormat.PDF); //Saves as PDF

This source code works perfect on my side. We have attached output PDF file for your reference. It may an issue with the environment. Please post your complete environment details in this forum thread. It’ll help us to be more specific. Please reply to the following questions:

  1. What is the Operating System name, edition and 32 & 64 bit (e.g. Windows 7 Ultimate 64 bit)
  2. What is the IDE (Netbeans, eclipse), edition and other details?
  3. What is the Java version, build number and 64 or 32 bits?
  4. Any other information that you think is necessary.

We’re looking forward to help you.

1. Windows 7 Professional 64-bit
2. Visual Studio 2012 V. 11.0.61030.00 Update 4
with Microsoft .Net Framework V 4.5.50709
3. Our Project is an ASP.NET C# Web Application using Framework .Net 4.5
CSharp V4.0.30319
4. Using Internet Explorer 9 in IE9 Compatibility mode.

I tested your cleaned up code verbatim aside from the filepaths, and I still error out so something else is going on here I guess..

If any other information is needed, let me know.


Hi Charles,


Thank you for providing us these details. We’re working to set up an environment and it will take a little time. We’ll get back to you in a couple of days.

Hi Charles,
ctenc001:
1. Windows 7 Professional 64-bit
2. Visual Studio 2012 V. 11.0.61030.00 Update 4
with Microsoft .Net Framework V 4.5.50709
3. Our Project is an ASP.NET C# Web Application using Framework .Net 4.5
CSharp V4.0.30319
4. Using Internet Explorer 9 in IE9 Compatibility mode.
Thank you for being patient. We've tested against the said environment. We're afraid that we could not reproduce the error message said. It looks an issue with your machine. Please run window updates or try it with any other machine. In case this does not help, then please prepare a sample application and reproduce the error message at your end. Also, provide us this sample application in this forum thread along with an error screenshot. We'll check and let you know about our findings.

The issues you have found earlier (filed as DIAGRAMNET-50236) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.