如何使用 itextsharp 将表格插入现有 PDF
有没有什么方法(使用 iTextSharp)来处理如下所示的 pdf 表单...其中:
1- 某些字段仅出现在第一页(表单顶部)
2- 某些字段仅出现在最后一页(表单底部)
3- 在使用前两部分生成表单后使用 C# 代码添加表格 并且该表消耗了不止一页(在前两页之间),
我执行了以下操作:
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();
但是该表覆盖了区域(2)和页脚中放置的内容,并且如果该表需要额外的页面,则不会创建新页面... .如何使表格根据需要将文档扩展为尽可能多的页面,最后在末尾写入region(2)
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(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.