Save PDF file as a byte array or stream using Rotativa

后端 未结 1 758
春和景丽
春和景丽 2021-01-13 15:32

I\'m trying to convert html to a PDF using Rotativa but I want to save at as a byte array or a stream so I can easily attach it to a mail or something. I found a solution he

1条回答
  •  爱一瞬间的悲伤
    2021-01-13 15:41

    I found the 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);
    

    0 讨论(0)
提交回复
热议问题