iTextSharp +OnEndPage
我正在尝试重写 OnEndPage 事件,但收到错误消息,指出没有找到合适的方法来重写
public override void OnEndPage(PdfWriter wri, Document doc)
{
PdfPTable table = new PdfPTable(1);
table.TotalWidth = doc.PageSize.Width - doc.LeftMargin - doc.RightMargin;
PdfPTable table2 = new PdfPTable(2);
PdfPCell cell2 = new PdfPCell(new Phrase("Test Top"));
cell2.Colspan = 2;
table2.AddCell(cell2);
cell2 = new PdfPCell(new Phrase("\nTitle", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 16, iTextSharp.text.Font.BOLD | iTextSharp.text.Font.UNDERLINE)));
cell2.HorizontalAlignment = Element.ALIGN_CENTER;
cell2.Colspan = 2;
table2.AddCell(cell2);
PdfPCell cell = new PdfPCell(table2);
table.AddCell(cell);
table.WriteSelectedRows(0, -1, doc.LeftMargin, doc.PageSize.Height - 37, wri.DirectContent);
}
Is 轻轻地坐落在两个按钮调用之间...我做错了什么吗?如果是的话,如果可能的话,是否可以提供包含整个 PDR/标头生成的完整源代码的示例?我没找到他们,我开始发疯了,哈哈,
谢谢你的帮助
I'm trying to override the OnEndPage event but I get the error message that there is no suitable method found to override
public override void OnEndPage(PdfWriter wri, Document doc)
{
PdfPTable table = new PdfPTable(1);
table.TotalWidth = doc.PageSize.Width - doc.LeftMargin - doc.RightMargin;
PdfPTable table2 = new PdfPTable(2);
PdfPCell cell2 = new PdfPCell(new Phrase("Test Top"));
cell2.Colspan = 2;
table2.AddCell(cell2);
cell2 = new PdfPCell(new Phrase("\nTitle", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 16, iTextSharp.text.Font.BOLD | iTextSharp.text.Font.UNDERLINE)));
cell2.HorizontalAlignment = Element.ALIGN_CENTER;
cell2.Colspan = 2;
table2.AddCell(cell2);
PdfPCell cell = new PdfPCell(table2);
table.AddCell(cell);
table.WriteSelectedRows(0, -1, doc.LeftMargin, doc.PageSize.Height - 37, wri.DirectContent);
}
Is gently nestled between two button calls... Am I doing something wrong? If I am, and if possible, can a example with full source for the entire PDR/Header generation be provided? I've had no luck finding them and I'm starting to go mad, haha
Thanks for any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建一个继承自 PdfPageEventHelper 的类,覆盖 OnStartPage 和 OnEndPage 并将该类的实例分配给 PdfWriter 实例的 PageEvent。
希望这有帮助
Create a class that inherits from PdfPageEventHelper override the OnStartPage and OnEndPage and assign the instance of that class to the PageEvent of PdfWriter instance.
Hope this helps