When savings a Visio document using the supplied code on the website page Convert Visio to HTML format|Documentation to a stream, the Aspose Diagram library is writing files to c:\main_files directory. It writes various HTML files and images files. This is not the expected nor desired outcome when saving to a stream. We are using the latest version of the Aspose Diagram product. Is this a bug or is there another way to save the entire contents of an HTML page to a single page and to a stream?
We’ve also attempted to insert and HTMLSaveOptions() object with the “SaveAsSingleFile” property set to “true” to no avail.
@srtrout_nsa_gov
Please refer to the sample code:
string outputDir = dataDir + @"output\";
// Create digaram
Diagram diagram = new Diagram(dataDir + "sample.vsdx");
Aspose.Diagram.Saving.HTMLSaveOptions options = new HTMLSaveOptions();
options.StreamProvider = new ExportStreamProvider(outputDir);
// Save into .html using HTMLSaveOptions
diagram.Save(dataDir + "output_out.html", options);
Here is the code for ExportStreamProvider class which implements IStreamProvider interface used inside the above code.
public class ExportStreamProvider : IStreamProvider
{
private string outputDir;
public ExportStreamProvider(string dir)
{
outputDir = dir;
}
public void InitStream(StreamProviderOptions options)
{
string path = outputDir + Path.GetFileName(options.DefaultPath);
options.CustomPath = path;
Directory.CreateDirectory(Path.GetDirectoryName(path));
options.Stream = File.Create(path);
}
public void CloseStream(StreamProviderOptions options)
{
if (options != null && options.Stream != null)
{
options.Stream.Close();
}
}
}
Please refer to the following documents:
Thank you for the response, but unfortunately this is not very helpful. The code sample you provided merely displaces writing files to “c:\main_files” by default to a different directory. The goal here is to not have files written to disk at all and to use streams for processing, ultimately returning a single stream that has all the components embedded in the stream as can be done with various other Aspose libraries.
When I set the HTMLSaveOptions.SaveAsSingleFile property to “true” and set the StreamProviderOptions.Stream to our output stream (a System.IO.MemoryStream), the output is garbled. Can you provide sample code to provide a single output stream to which to save a converted Visio Diagram as HTML with all objects embedded?
Thank you.
@srtrout_nsa_gov
We are checking this issue and will soon get back to you.
Thanks.
@srtrout_nsa_gov
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): DIAGRAMNET-53190
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
The issues you have found earlier (filed as DIAGRAMNET-53190) have been fixed in this update. This message was posted using Bugs notification tool by philip.zhou