How to remove private information, unused shapes, data graphics and styles using Aspose Diagram?

I have a Visio diagram. It contains some private information, unused shapes, data graphics and styles. Is there is any way to Remove unused themes, data graphics and styles programmatically.Sample.zip (47.4 KB)

Thanks,
Renga

@rengnext

Thanks for contacting support.

We have logged your requirements under a ticket ID DIAGRAMNET-51606 in our issue tracking system. We will further investigate them and as soon as logged ticket is resolved, we will surely inform you. Please be patient and spare us little time.

We are sorry for the inconvenience.

@rengnext

We would like to share with you that we are working over providing feature to retrieve themes from Diagram and as soon as the feature is available, we will surely let you know. Furthermore, you may please use diagram.StyleSheets[] to get styles.

Hi Asad,

Thanks for your answer.

Actually we would like to reduce the visio size: by removing the Personal information, Unused Master shapes/Stencils, Styles …

Right now, we use ‘MS visio introp’ to remove those informations like,

The code:
[TestMethod]
public void TestRemoveVisioUnwantedInfo()
{
// Arrange
StringBuilder sb = new StringBuilder();

Type VisioType = Type.GetTypeFromProgID("Visio.Application");
if(VisioType == null)
{
	sb.AppendLine("Visio is not installed.");
	return;
}
InvisibleApp visioApplication = new InvisibleApp
{
	Visible = false,
	AlertResponse = 1
};

Document visioDoc = null;
string[] files = Directory.GetFiles(@"C:\Temp\change_visio\");

// Act
foreach(string strFile in files)
{
	try
	{
		short args = (short) VisOpenSaveArgs.visOpenMacrosDisabled + (short) VisOpenSaveArgs.visOpenDontList;

		visioDoc = visioApplication.Documents.OpenEx(strFile, args);
		visioDoc.RemoveHiddenInformation((int) VisRemoveHiddenInfoItems.visRHIPersonalInfo +
										 (int) VisRemoveHiddenInfoItems.visRHIMasters +
										 (int) VisRemoveHiddenInfoItems.visRHIPreview +
										 (int) VisRemoveHiddenInfoItems.visRHIStyles +
										 (int) VisRemoveHiddenInfoItems.visRHIValidationRules +
										 (int) VisRemoveHiddenInfoItems.visRHIDataRecordsets);


		visioDoc.SaveAs(strFile);
	}
	catch(Exception ex)
	{
		sb.AppendLine("Removing Visio unwanted info is failed - Filename: \t" + strFile);
		sb.AppendLine("Error: \t" + ex.Message + ex.StackTrace);
		sb.Append(Environment.NewLine);
	}
	finally
	{
		visioDoc?.Close();
	}

	if(!File.Exists(strFile)) continue;
	// TODO				
}

visioApplication.Quit();

Marshal.ReleaseComObject(visioApplication);

// Assert

}

But we need to do the above work via Aspose.diagram. We are waiting for your positive reply.

Thank you.

@rengnext

Thanks for providing these details.

We have logged these details as well along with the earlier logged ticket. As shared earlier, we are already working over providing feature to get themes from Diagram, we will definitely consider your other requirements as well during investigation. As soon as some definite updates are available regarding feature availability, we will let you know.

Hi Asad,

We hope you are working in this work (ticket ID: DIAGRAMNET-51606).

Could you please let us know the status? Because of this issue our work is in pending.

Thank you.

@rengnext

The implementation of the required feature needs some time and we assure you that we intend to provide this feature soon. However, we regret to share that we cannot share any reliable ETA for now due to other pending issues in the queue. We have recorded your concerns and will definitely consider them during investigation process. As soon as we have some definite updates to share, we will let you know. Please spare us little time.

We are sorry for the inconvenience.

Hi Asad,

We hope you are working in this work (ticket ID: DIAGRAMNET-51606 ).

Could you please let us know the status? Because of this issue our work is in pending.

Thank you.

@rengnext

We are afraid that earlier logged ticket is not yet resolved. We have been working over implementing this feature as well as resolving other reported issues in the queue. As soon as required feature is available in the API, we will surely inform you. We greatly appreciate your patience in this regard.

@rengnext

Could you please try using following code snippet with Aspose.Diagram for .NET 19.4 and in case it resolves your issue, we will be proceeding further to resolve the logged ticket:

diagram.RemoveHiddenInformation((int)(RemoveHiddenInfoItem.Shapes | RemoveHiddenInfoItem.Masters));

@asad.ali

Thanks for your reply.

We tested the issue with new Aspose Diagram for .NET 19.4. It’s seems reduced the file size (18 KB to 16KB). But still the unused Master shapes, styles are retained in the Visio file. So we have attached the Viso file.

Input: Test_Visio.zip (14.1 KB)

Output:Test_Visio_Output.zip (13.3 KB)

Could you please have a look at this?

Thank You.

@rengnext

Thanks for your feedback.

We will further look into the scenario accordingly and share additional updates with you.

@asad.ali,

We hope you are working on this work (ticket ID: DIAGRAMNET-51606).

Could you please let us know the status? Because of this issue our work is in pending for last 4 weeks.

Sorry for the frequent interruption.

Thank you.

@rengnext

We would like to share with you that issue of removing unused Master shapes, styles has been fixed in Aspose.Diagram for .NET 19.5 which soon will be available for download. As soon as the API revision is released, we will notify you.

@asad.ali

Thanks for the great info. We are waiting for the new version. :slightly_smiling_face:

Thanks

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

@asad.ali,

Thanks for the update. The issue is fixed. Removing master shapes are working fine. :slight_smile:

But I have tested some other file. It’s show exception.

Input: Test2.zip (53.9 KB)

Exception : Exception.png (15.7 KB)

Note: The Personal Info (Like Author, Company, Title… etc.) is not removed. Please check that also.

We are waiting for your reply.

Thanks.

@rengnext

Thanks for your feedback.

Furthermore, we were also able to notice the exception while working with your shared file. We have logged another issue as DIAGRAMNET-51643 in our issue tracking system. We will check the issue in details and keep you informed with its resolution status. Please spare us little time.

We are sorry for the inconvenience.

@asad.ali,

We hope you are working on this work (ticket ID: DIAGRAMNET-51643 ).

Could you please let us know the status? Because of this issue our work is in pending for last 4 weeks.

Sorry for the frequent interruption.

Thank you.

@rengnext

We would like to share with you that fix of the issue has been planned for upcoming version Aspose.Diagram for .NET 19.6. As soon as new version of API is available, we will surely let you know.