We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert html string to pdf stream dotnet core

How can I create stream of pdf from html string in dotnet core?

@MmY

You can use the below code snippet to initialize a PDF document from HTML string and save it into a stream:

string demo = "<html><head><title>Hello</title></head><body><h1>Hallo Welt</h1></body></html>";
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(demo));
HtmlLoadOptions loadoptions = new HtmlLoadOptions(dataDir);
loadoptions.PageInfo.Margin = new MarginInfo(0, 0, 0, 0);
loadoptions.PageInfo.Height = Aspose.Pdf.PageSize.PageLetter.Height;
loadoptions.PageInfo.Width = Aspose.Pdf.PageSize.PageLetter.Width;
Document doc = new Document(ms, loadoptions);
MemoryStream pdf = new MemoryStream();
doc.Save(pdf);