Save PDF file as byte array or stream using Rotativa

I am trying to convert html to PDF using Rotativa, but I want to save it as an array of bytes or a stream so that I can easily attach it to mail or something else. I found a solution here , but the file cannot be opened by any PDF reader, because it is not a supported format or the file is damaged.

Here is another solution from the same thread, but I can’t understand what parameters need to be passed to this function, and I could not find any documentation for Rotativa online.

+1
source share
1 answer

I found a solution here

var actionPDF = new Rotativa.ActionAsPdf("YOUR_ACTION_Method", new { id = ID, lang = strLang } //some route values) { //FileName = "TestView.pdf", PageSize = Size.A4, PageOrientation = Rotativa.Options.Orientation.Landscape, PageMargins = { Left = 1, Right = 1 } }; byte[] applicationPDFData = actionPDF.BuildPdf(ControllerContext); 
+7
source

Source: https://habr.com/ru/post/1205708/


All Articles