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

Free Support Forum - aspose.com

Setting document properties do not work?

I try to set different properties in diagram but it seems not to work at all:

var diagramProperties = _diagram.DocumentProps;
diagramProperties.Title = “sample title”;

works

but
diagramProperties.Creator = “test1”;
diagramProperties.Manager = “test2”;

do not work. I did not test all other built in so far…

Also I want to add custom property values which do not work too for me atm:

var customProperties = diagramProperties.CustomProps;
for (var i = 0; i < customProperties.Count; i++)
{
if (customProperties[i].Name == name && customProperties[i].PropType == PropType.String)
customProperties[i].CustomValue.ValueString = value;
}

Something I do wrong ???

Hi Yves,


Thank you for contacting support. We’re working over query and will get back to you soon.

Hi Yves,


Thank you for being patient. We’ve tested your lines of code against our sample Visio diagram and the latest version 5.8.0 of the Aspose.Diagram for .NET API. We’re able to set Visio document properties and add / retrieve custom document properties. Please download and use the latest version 5.8.0 of the Aspose.Diagram for .NET API and let us know how it goes on your side. In case, this does not help, then please provide us your complete details of the use case and resources. We’ll investigate and reply you appropriately.

Hello,

thank you for your tests. I downloaded the latest version again and retried. Still same results. So I post some detailed information.

My Test code of my class (attached the visio test files and the visio.cs):

// test visio
Console.WriteLine("*** VISIO ***");
var vsd = new Visio { Company = company };
Console.WriteLine(vsd.Load(testFilesPath + “visio.vsd”));
Console.WriteLine(“Source file type is:” + vsd.FileFormat);
// list available form fields
Console.WriteLine(vsd.FormFields()); // not implemented yet

// set document properties
vsd.SetProperty(“author”, “Mr. Spunt”);
vsd.SetProperty(“manager”, “Sir Pipo”);
vsd.SetProperty(“title”, “sample title”);
vsd.SetProperty(“guid”, Guid.NewGuid().ToString());

// set formfields
vsd.SetFormFieldValue(“FIELD1”, DateTime.Now.ToString()); // not implemented yet
vsd.SetFormFieldValue(“FIELD2”, “SAMPLE TEXT”); // not implemented yet

// save document
vsd.SaveAs(testFilesPath + @“out\visio_output.vsdx”, “vsdx”);

// reload to check values
vsd.Load(testFilesPath + @“out\visio_output.vsdx”);

// show properties
Console.WriteLine("author: " + vsd.GetProperty(“author”));
Console.WriteLine("guid: " + vsd.GetProperty(“guid”));
Console.WriteLine("manager: " + vsd.GetProperty(“manager”));
Console.WriteLine("title: " + vsd.GetProperty(“title”));

// show values
Console.WriteLine("FIELD1: " + vsd.GetFormFieldValue(“FIELD1”));
Console.WriteLine("FIELD2: " + vsd.GetFormFieldValue(“FIELD2”));

// create pdf document
vsd.SaveAs(testFilesPath + @“out\visio_output.pdf”, “pdf”);

Console.WriteLine(“DONE…”);
Console.ReadKey();

Hi Yves,


Thank you for posting a source Visio diagram along with the sample code. We have simplified your sample code. It applies a license, load the Visio diagram, set creator, manager and title properties and then save it in the VSDX format. There is no Custom “guid” property in the source Visio diagram. Since it does not set any custom property. In the second part of your code, you are retrieving and displaying these properties from the resultant VSDX diagram. This use case works fine on our side using the latest version 5.8.0 of the Aspose.Diagram API. Please check this simplified code and its results below:

[.NET, C#]
// apply a license
string licFilePath = @“C:\temp\Aspose.Total.lic”;
Aspose.Diagram.License licDiagram = new Aspose.Diagram.License();
licDiagram.SetLicense(licFilePath);

// load VSD diagram and set its properties
Diagram diagram = new Diagram(@“C:\temp\visio.vsd”);
diagram.DocumentProps.Creator = “Mr. Spunt”;
diagram.DocumentProps.Manager = “Sir Pipo”;
diagram.DocumentProps.Title = “sample title”;

for (var i = 0; i < diagram.DocumentProps.CustomProps.Count; i++)
{
if (diagram.DocumentProps.CustomProps[i].Name == “guid” && diagram.DocumentProps.CustomProps[i].PropType == PropType.String)
diagram.DocumentProps.CustomProps[i].CustomValue.ValueString = Guid.NewGuid().ToString();
}
// save in the VSDX format
diagram.Save(@“C:\AD\test534\visio_output.vsdx”, SaveFileFormat.VSDX);

// load the resultant VSDX diagram and get its properties
Diagram outDiagram = new Diagram(@“C:\temp\visio_output.vsdx”);
Console.WriteLine("author: " + outDiagram.DocumentProps.Creator);

string guide = “”;
for (var i = 0; i < outDiagram.DocumentProps.CustomProps.Count; i++)
{
if (outDiagram.DocumentProps.CustomProps[i].Name == “guid”)
guide = outDiagram.DocumentProps.CustomProps[i].CustomValue.ToString();
}
Console.WriteLine("guid: " + guide);
Console.WriteLine("manager: " + diagram.DocumentProps.Manager);
Console.WriteLine("title: " + diagram.DocumentProps.Title);
Results:
author: Mr. Spunt guid: manager: Sir Pipo title: sample title
We hope, this helps. Please let us know in case of any ambiguity or questions.

Here we go,

for the custom property I forgot to add it before. Me only handled existing ones…
So now I add

customProperties.Add(new CustomProp {Name = name, PropType = PropType.String, CustomValue = {ValueString = value}});

if the custom property name is not found. The document contains the custom property with its value now.

Strange thing is reading it.

return customProperties[i].CustomValue.ToString();

or

return customProperties[i].CustomValue.ValueString;

returns “Aspose.Diagram.CustomProp” instead of the value.

About built in properties it is strange as well:

The following code can e.g. set “author” ( => .Creator ) but not Keywords or Manager:

public void SetProperty(string name, string value)
{
if (string.IsNullOrEmpty(_path)) return;
var diagramProperties = _diagram.DocumentProps;

switch (name.ToLower())
{
case “category”:
diagramProperties.Category = value;
break;
case “author”:
diagramProperties.Creator = value;
break;
case “manager”:
diagramProperties.Manager = value;
break;
case “keywords”:
diagramProperties.Keywords = value;
break;
case “subject”:
diagramProperties.Subject = value;
break;
case “title”:
diagramProperties.Title = value;
break;
// custom property
default:
var customProperties = diagramProperties.CustomProps;
for (var i = 0; i < customProperties.Count; i++)
{
if (customProperties[i].Name != name || customProperties[i].PropType != PropType.String) continue;
customProperties[i].CustomValue.ValueString = value;
break;
}
customProperties.Add(new CustomProp {Name = name, PropType = PropType.String, CustomValue = {ValueString = value}});
break;
}
}

Hi Yves,


Thank you for the details.
rausch:
if the custom property name is not found. The document contains the custom property with its value now.

Strange thing is reading it.
return customProperties[i].CustomValue.ToString();
or
return customProperties[i].CustomValue.ValueString;

returns “Aspose.Diagram.CustomProp” instead of the value.
We managed to replicate the problem of incorrect custom property value. We have logged it under ticket id DIAGRAMNET-50644 in our bug tracking system. Your post has also been linked to this issue. We’ll keep you informed regarding any available updates. We’re sorry for the inconvenience caused.

In reference of the built-in properties, we can set and retrieved all these properties as follows:

[.NET, C#]
// load VSD diagram and set its properties
Diagram diagram = new Diagram(@“C:\temp\visio.vsd”);

diagram.DocumentProps.Category = “Some Category”;
diagram.DocumentProps.Creator = “Mr. Spunt”;
diagram.DocumentProps.Manager = “Sir Pipo”;
diagram.DocumentProps.Keywords = “Keywords”;
diagram.DocumentProps.Title = “sample title”;
diagram.DocumentProps.Subject = “Some Subject”;

// save in the VSDX format
diagram.Save(@“C:\temp\Aspose_out.vsdx”, SaveFileFormat.VSDX);

// load the resultant VSDX diagram and get its properties
Diagram outDiagram = new Diagram(@“C:\temp\Aspose_out.vsdx”);
Console.WriteLine("category: " + outDiagram.DocumentProps.Category);
Console.WriteLine("author: " + outDiagram.DocumentProps.Creator);
Console.WriteLine("manager: " + diagram.DocumentProps.Manager);
Console.WriteLine("keywords: " + diagram.DocumentProps.Keywords);
Console.WriteLine("title: " + diagram.DocumentProps.Title);
Console.WriteLine("subject: " + diagram.DocumentProps.Subject);

Results:
category: Some Category
author: Mr. Spunt
manager: Sir Pipo
keywords: Keywords
title: sample title
subject: Some Subject

We hope, this helps. Please let us know in case of any ambiguity or questions.

Hi Yves,


Thank you for being patient. We have a good news for you that the issue id DIAGRAMNET-50644 has now been resolved. If there is no issue in the QA phase, then this fix will be included in the next version of Aspose.Diagram for .NET 5.9.0. We’ll inform you via this forum thread as soon as the new release is published.

The issues you have found earlier (filed as DIAGRAMNET-50644) have been fixed in Aspose.Diagram for .NET 5.9.0.


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

I tested and it works now for me, thank you. Interesting that the history of bugfixes do not list the fix :).

I still facing the problem that manager and keyword can not be set, only author works. But this may be possible problem of my code, when I have more time I will take a deeper look at this.

Hi Yves,


Thank you for writing to us. As we narrated earlier that the Aspose.Diagram API can set and get built in properties and the problem of custom property value has also been fixed in the latest version 5.9.0. Sure, please take your time and if the problem remains of not setting Manager and Keyword properties, then please provide us the complete details of your development environment. It’ll help us, please reply to the following questions:

  • What is the Operating System name, edition and 32 & 64 bit (e.g. Windows 7 Ultimate 64 bit)
  • What is the .NET Framework version?
  • Which IDE are you using and what is the build version and edition e.g. Visual Studio Professional 2015
  • What is the local language and settings, etc.?
  • Any other information that you think is necessary.

It would be great if can please prepare a sample project which reproduces this error message and attach its zip file in this forum thread. We’re looking forward to help you.

Hello,

came back to the project and now found time for this.

System one:
OS: Windows 2008 R2
.NET: Version 4
IDE: VS 2010
Local settings: german locale

System two:
OS: Windows 2012 R2
.NET: Version 4
IDE: VS 2015
Local settings: english locale

Both system same effect.

My test code:

// test visio
Console.WriteLine("*** VISIO ***");
var vsd = new Visio { Company = company };
Console.WriteLine(vsd.Load(testFilesPath + “visio.vsd”));
Console.WriteLine(“Source file type is:” + vsd.FileFormat);
// list available form fields
[//Console.WriteLine](https://console.writeline/)(vsd.FormFields()); // not implemented yet

// set document properties
vsd.SetProperty(“author”, “Mr. Spunt”);
vsd.SetProperty(“manager”, “Sir Pipo”);
vsd.SetProperty(“title”, “sample title”);
vsd.SetProperty(“keywords”, “key1 key2 key3”);
vsd.SetProperty(“guid”, Guid.NewGuid().ToString());

// set formfields
[//vsd.SetFormFieldValue](https://vsd.setformfieldvalue/)(“FIELD1”, DateTime.Now.ToString()); // not implemented yet
[//vsd.SetFormFieldValue](https://vsd.setformfieldvalue/)(“FIELD2”, “SAMPLE TEXT”); // not implemented yet

// save document
vsd.SaveAs(testFilesPath + @“out\visio_output.vsdx”, “vsdx”);

// reload to check values
vsd.Load(testFilesPath + @“out\visio_output.vsdx”);

// show properties
Console.WriteLine("author: " + vsd.GetProperty(“author”));
Console.WriteLine("guid: " + vsd.GetProperty(“guid”));
Console.WriteLine("manager: " + vsd.GetProperty(“manager”));
Console.WriteLine("keywords: " + vsd.GetProperty("keywords "));
Console.WriteLine("title: " + vsd.GetProperty(“title”));

// show values
Console.WriteLine("FIELD1: " + vsd.GetFormFieldValue(“FIELD1”));
Console.WriteLine("FIELD2: " + vsd.GetFormFieldValue(“FIELD2”));

// create pdf document
vsd.SaveAs(testFilesPath + @“out\visio_output.pdf”, “pdf”);

Console.WriteLine(“DONE…”);
Console.ReadKey();

I add the class I use and the test visio file as archive so you can have a look.

Hi Yves,


Thank you for the details. We have tested your Visio diagram against the latest version 6.1.1.0 of Aspose.Diagram API and figured out the problem of the empty string in case of the Manager property. We have logged this problem under ticket id DIAGRAMNET-50717 in our bug tracking system. We’ll keep you informed regarding any available updates. We’re sorry for the inconvenience caused.

Please download and use the latest Hotfix version: Aspose.Diagram for .NET 6.1.1.0 and let us know how it goes on your side. We’ve simplified your sample code as follows:

[.NET, C#]
Diagram diagram = new Diagram(@“C:\AD\test613\visio.vsd”);
diagram.DocumentProps.Creator = “Mr. Spunt”;
diagram.DocumentProps.Manager = “Sir Pipo”;
diagram.DocumentProps.Title = “sample title”;
diagram.DocumentProps.Keywords = “key1 key2 key3”;

string value = Guid.NewGuid().ToString();
CustomPropCollection CusProps = diagram.DocumentProps.CustomProps;
for (var i = 0; i < CusProps.Count; i++)
{
if (CusProps[i].Name != “guid” || CusProps[i].PropType != PropType.String) continue;
CusProps[i].CustomValue.ValueString = value;
break;
}
CusProps.Add(new CustomProp { Name = “guid”, PropType = PropType.String, CustomValue = { ValueString = value } });

diagram.Save(@“C:\AD\test613\visio_output.vsdx”, SaveFileFormat.VSDX);
diagram = new Diagram(@“C:\AD\test613\visio_output.vsdx”);

Console.WriteLine("author: " + diagram.DocumentProps.Creator);
CustomPropCollection customProperties = diagram.DocumentProps.CustomProps;
for (var i = 0; i < customProperties.Count; i++)
{
if (customProperties[i].Name == “guid”)
Console.WriteLine("guid: " + customProperties[i].CustomValue.ValueString);
}
Console.WriteLine("manager: " + diagram.DocumentProps.Manager);
Console.WriteLine("keywords: " + diagram.DocumentProps.Keywords);
Console.WriteLine("title: " + diagram.DocumentProps.Title);

diagram.Save(@“C:\AD\test613\visio_output.pdf”, SaveFileFormat.PDF);
Console.WriteLine(“DONE…”);
Console.ReadKey();

Results:
-------------
author: Mr. Spunt guid: a227a973-aa7c-4d75-99f2-0305b9ee1a04 manager: keywords: key1 key2 key3 title: sample title

With latest DLL from hotfix download I can approve that all values except manager like your result now are printed out with your simplified code as well as my code.

Hi Yves,


Thank you for the confirmation. We have logged this problem in our bug tracking system and will let you know once it is resolved.

Hi Yves,


Thank you for being patient. We have a good news for you that the issue id DIAGRAMNET-50717 has now been resolved. If there is no issue in the QA phase, then this fix will be included in the next version of Aspose.Diagram for .NET 6.2.0. We’ll inform you via this forum thread as soon as the new release is published.

The issues you have found earlier (filed as DIAGRAMNET-50717) have been fixed in Aspose.Diagram for .NET 6.2.0.


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