public async Task <IActionResult> Post(DinkToPdfModel model)
        {
            var headerFilePath = await _fileCommands.CreateTempFile(model.HeaderHtml, "html");

            var footerFilePath = await _fileCommands.CreateTempFile(model.FooterHtml, "html");

            var doc = new HtmlToPdfDocument
            {
                GlobalSettings = model.GlobalSettings,
                Objects        =
                {
                    new ObjectSettings
                    {
                        HeaderSettings = new HeaderSettings{
                            HtmUrl = headerFilePath
                        },
                        HtmlContent    = model.Html,
                        FooterSettings = new FooterSettings{
                            HtmUrl = footerFilePath
                        },
                    }
                }
            };

            return(new FileContentResult(_converter.Convert(doc), "application/pdf"));
        }
Ejemplo n.º 2
0
        public static string GetBody(string html, string headerHtml, string footerHtml)
        {
            var model = new DinkToPdfModel
            {
                Html           = html,
                FooterHtml     = footerHtml,
                HeaderHtml     = headerHtml,
                GlobalSettings = GetSettings()
            };

            return(JsonSerializer.Serialize(model));
        }