Free Support Forum - aspose.com

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


#1

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


#2

@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.


#3

@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.


#4

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.


#5

@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.