Ejemplo n.º 1
0
        public async Task ExportPdfBytesByTemplate_Test()
        {
            var tplPath  = Path.Combine(Directory.GetCurrentDirectory(), "TestFiles", "ExportTemplates", "tpl1.cshtml");
            var tpl      = File.ReadAllText(tplPath);
            var exporter = new PdfExporter();
            var filePath = Path.Combine(Directory.GetCurrentDirectory(), nameof(ExportPdfBytesByTemplate_Test) + ".pdf");

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }
            //此处使用默认模板导出
            var result = await exporter.ExportListBytesByTemplate(
                GenFu.GenFu.ListOf <ExportTestData>(), tpl);

            result.ShouldNotBeNull();
            using (var file = File.OpenWrite(filePath))
            {
                file.Write(result, 0, result.Length);
            }

            File.Exists(filePath).ShouldBeTrue();
        }
Ejemplo n.º 2
0
 public async Task ExportPdfAsByteArrayTest()
 {
     await _exporter.ExportListBytesByTemplate(_exportTestData, tpl);
 }