Generate stream from HTML2PDF


Can we just get pdf stream, instead of saving it to file?

using (var doc = new PDFDoc()) { var converter = new HTML2PDF(); converter.InsertFromHtmlString(htmlTemplate); HTML2PDF.SetModulePath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Constants.Api.Properties.AppData, Constants.Api.Properties.Dependencies)); if (!converter.Convert(doc)) return null; doc.Save(fileFullPath, SDFDoc.SaveOptions.e_linearized); // Can we avoid this step and return an byte[] or stream }


Yes the PDFDoc class has various save methods.

PDFDoc.Save to byte[]
PDFDoc Save to stream

Please note though, that the HTML2PDF process itself always writes to disk at some point during the conversion, to a temporary file location. Currently there is no way to avoid.