Save PDF file as a byte array or stream using Rotativa

依然范特西╮ 提交于 2019-12-01 23:06:41

问题


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 here but the file can't be opened by any PDF reader because it's not a supported format or the file is corrupted.

Here is another solution from the same thread but I can't figure out what is the required parameters to pass to this function and I couldn't find any documentation for Rotativa online.


回答1:


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);


来源:https://stackoverflow.com/questions/32181904/save-pdf-file-as-a-byte-array-or-stream-using-rotativa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!