使用iTextSharp从原始PDF中复制多个PDF

时间:2017-09-12 09:48:10

标签: itext

我使用iTextSharp以PDF格式创建发票。

现在我需要创建该PDF的多个副本,添加诸如" DUPLICATE"," TRIPLICATE"等标题,等等。

这可能吗?

                    Document pdfDoc = new Document(PageSize.A4, 20, 25, 25, 10);
                    System.IO.FileStream file = new System.IO.FileStream(Server.MapPath("~/" + fileUploadLoc + "/" + "File.pdf", System.IO.FileMode.OpenOrCreate);
                    PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDoc, file);
                    fileName = Convert.ToString("Invoice.pdf");
                    pdfDoc.Open();
                    pdfWriter.Open();

                    PdfPTable nested = new PdfPTable(1);
                    nested.DefaultCell.Border = Rectangle.BOX;
                    nested.WidthPercentage = 100;

                    PdfPCell Tableheader = new PdfPCell(new Phrase("Company Name", titleHeaderFont));
                    Tableheader.HorizontalAlignment = 1;
                    Tableheader.Border = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER | Rectangle.TOP_BORDER;
                    Tableheader.Left = 45f;
                    Tableheader.Right = 45f;
                    table.AddCell(Tableheader);


                    PdfPCell Tableheader7 = new PdfPCell(new Phrase("Triplicate for Supplier", fontsize7normaol));

////必须在每个新的pdf中更改上面的行

                    Tableheader7.HorizontalAlignment = 1;
                    Tableheader7.Border = Rectangle.LEFT_BORDER | 
                    Rectangle.RIGHT_BORDER | Rectangle.BOTTOM_BORDER | 
                    Rectangle.TOP_BORDER;
                    Tableheader7.Right = 25f;
                    nested1.AddCell(Tableheader7);

                    pdfDoc.Add(table);
                    pdfWriter.CloseStream = false;
                    pdfDoc.Close();

0 个答案:

没有答案
相关问题