Exemplo n.º 1
0
        private static void GenerateInvoice()
        {
            var data = GetInvoiceData();

            var cfg = new PdfConfig
            {
                FontPaths = new [] { "/Library/Fonts" } // this is configured for mac, on windows you have to change it
            };

            var bytes = Templator.Create("Template/invoice.xml")
                        .UsePdfRenderer(cfg)
                        .Render(data);

            File.WriteAllBytes("Result/invoice.pdf", bytes);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnGetAsync()
        {
            var cfg = new PdfConfig
            {
                FontPaths = new[] { "/Library/Fonts" },
            };

            var bytes = Templator
                        .Create("print.xml")
                        .UsePdfRenderer(cfg)
                        .Render(GetData());

            await Task.CompletedTask;

            return(this.File(bytes, "application/pdf"));
        }