how to insert a table into existing PDF using itextsharp

主宰稳场 提交于 2019-12-12 01:48:57

问题


Is there any way (using iTextSharp) to work with a pdf form like the following one ... where :

1- some fields to appear in the first page only ( Top of the form )
2- some fields to appear in the last page only ( Bottom of the form )

3- table to be added using C# code after the form is generated with the the first two sections and the table me consume more than one page ( between the first two )

I did the following :

        FillTable();
        Byte[] buffer = System.IO.File.ReadAllBytes(@"C:\Users\mahmod\Desktop\PDFform.pdf");
        string newFile = @"C:\Users\mahmod\Desktop\output.pdf";
        PdfReader reader = new PdfReader(buffer);
        PdfStamper pdfStamper = new PdfStamper(reader, new FileStream(newFile, FileMode.Open));
        table.SetTotalWidth(new float[] { 100, 100 });
        table.WriteSelectedRows(0, -1, 200, 200, pdfStamper.GetOverContent(1));
        pdfStamper.Close();

but the table overwrites the the content placed in region(2) and the footer and if the table needs extra pages no new pages created ....how to make the table extend the document by as much pages as needed and finally writing region(2) at the end


回答1:


Yes, this is all possible. Without more specific details, however, I'm just going to point you to a couple of articles that will hopefully get you started.

  • Fill in PDF Form Fields using the Open Source iTextSharp DLL
  • How to position a table at a specific x,y coordinate


来源:https://stackoverflow.com/questions/7702743/how-to-insert-a-table-into-existing-pdf-using-itextsharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!