Thanks for your inquiry. You may achieve your requirement by saving output HTML into static stream. Please check following sample code for the purpose.
// it can be any writable stream, file
stream used only as example <o:p></o:p>
static Stream
_staticOutStream = File.OpenWrite(@"F:\ExternalTestsData\static_stream_out.html");
public static void PDFtoStaticHTMLStream_37952()
{
Document doc = new
Document(@"F:\ExternalTestsData\HelloWorld.pdf");
// tune conversion params for first saving
HtmlSaveOptions newOptions = new HtmlSaveOptions();
newOptions.RasterImagesSavingMode = HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground;
newOptions.FontSavingMode = HtmlSaveOptions.FontSavingModes.SaveInAllFormats;
newOptions.PartsEmbeddingMode = HtmlSaveOptions.PartsEmbeddingModes.EmbedAllIntoHtml;
newOptions.LettersPositioningMethod = HtmlSaveOptions.LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss;
newOptions.SplitIntoPages = false;// force write HTMLs of all pages into one output document
newOptions.CustomHtmlSavingStrategy = new
HtmlSaveOptions.HtmlPageMarkupSavingStrategy(SavingToStaticStream);
//we can use some non-existing puth as result file name -
all real saving will be done
//in our custom method SavingToStream() (it's follows this
one)
string outHtmlFile = @"Z:\SomeNonExistingFolder\HelloWorld.html";
doc.Save(outHtmlFile, newOptions);
}
private static void SavingToStaticStream(HtmlSaveOptions.HtmlPageMarkupSavingInfo htmlSavingInfo)
{
Console.WriteLine("Starting
saving to static stream of output HTML document '" +
htmlSavingInfo.SupposedFileName + "' ...");
byte[] resultHtmlAsBytes = new
byte[htmlSavingInfo.ContentStream.Length];
htmlSavingInfo.ContentStream.Read(resultHtmlAsBytes, 0,
resultHtmlAsBytes.Length);
// locking allows to ensure that saving to static stream
// goes from one thread a time and allows avoid
interference
// between different threads(if any) during saving to same
output thread
lock (_staticOutStream)
{
_staticOutStream.Write(resultHtmlAsBytes, 0, resultHtmlAsBytes.Length);
}
Console.WriteLine("Output
HTML document '" + htmlSavingInfo.SupposedFileName + "' has been successfully saved to static
stream.");
}
Please feel free to contact us for any further assistance.
Best Regards,