Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created January 18, 2021 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/166e396658c6aa55e36dfcdaaa9bfb93 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/166e396658c6aa55e36dfcdaaa9bfb93 to your computer and use it in GitHub Desktop.
C# MemoryStream to File | Convert PDF File to MemoryStream C#
var inputFile = dataDir + @"Test.pdf";
string fnameppt = dataDir + "Test.pptx";
{
Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(inputFile);
using (MemoryStream pptStream = new MemoryStream())
{
pdfDoc.Save(pptStream, Aspose.Pdf.SaveFormat.Pptx);
//File.WriteAllBytes(fnameppt, pptStream.ToArray());
}
}
// Specify HtmlLoadOptions to load input file
HtmlLoadOptions options = new HtmlLoadOptions();
var fileName = dataDir + "Test.html";
string pdfFileName = dataDir + "Test.pdf";
Document document = null;
// Load input HTML file in MemoryStream
using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(File.ReadAllText(fileName))))
{
// Initialize a doument from input MemoryStream
document = new Document(ms, options);
// Save the MemoryStream to PDF file
document.Save(pdfFileName);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment