Generate stream from HTML2PDF

77 views
Skip to first unread message

Ryan

unread,
Jul 28, 2016, 12:53:24 PM7/28/16
to PDFTron PDFNet SDK
Question:

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
}


Answer:

Yes the PDFDoc class has various save methods.


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.
Reply all
Reply to author
Forward
0 new messages