Problems by creating Multiple PDFs

后端 未结 2 1934
旧巷少年郎
旧巷少年郎 2021-01-24 15:39

I succeeded in creating a single pdf, but how can I design a loop for file names? The Problem is every Loop my file will be overwritten

I tried to add a variable to the

2条回答
  •  攒了一身酷
    2021-01-24 16:15

    Thanks, you helped me a lot! This is the Code that works for me:

    var pdf1 =
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
                strGPNrVar + "_" + DateTime.Now.ToString("yyyy-MM-dd-hh.mm.ss")
                + $"_Report.pdf");
                using (FileStream fs = new FileStream(pdf1, FileMode.Create,
                FileAccess.Write, FileShare.None))
               {
    
                Document document = new Document(PageSize.A4);
                PdfWriter writer = PdfWriter.GetInstance(document, fs);
    

提交回复
热议问题