Exemplo n.º 1
0
        public PdfDocument GetPdf(VM.Invoice invoice)
        {
            var baseUrl             = AppHelpers.BaseUrl(_httpContextAccessor);
            var invoiceHtmlFilePath = "DocumentTemplates/Invoice/Templates/invoice.html";
            var footerHtmlFilePath  = "DocumentTemplates/Invoice/Templates/Assets/footer.html";

            var footerPath = $"{baseUrl}/invoice-assets/footer.html";

            HtmlToPdf Renderer   = new HtmlToPdf();
            var       html       = _htmlRenderService.Render <VM.Invoice>(invoiceHtmlFilePath, invoice);
            var       footerHtml = _htmlRenderService.Render <VM.Invoice>(footerHtmlFilePath, invoice);
            var       doc        = Renderer.RenderHtmlAsPdf(html);

            doc.AddHTMLFooters(new HtmlHeaderFooter()
            {
                HtmlFragment = footerHtml,
                Height       = 30
            });
            return(doc);
        }