获取报表页眉和页脚重复在每一页上应该是相当直截了当。
现在,如果你有报告内容之外的一些附加信息,你想重复每一页上,你可以做到以下几点:
正如你可能已经知道,使用的Tablix时,有可能在重复表格标题行每页。通过将Tablix添加到单个列并使其跨越页面的大小,在添加矩形的标题和数据行中,这可以用于我们的优势,因此它就像报表主体一样。在标题行中,您可以在下一页添加您希望重复的任何数据/文本。
现在,如果您希望页面的背面有文字,您可能不希望在每个页面上重复该操作。由于页面的后面始终是相同的静态数据,因此您可以按照现在设置的方式生成报告,并在报告页面之间插入静态页面。
为了更好地实现的最后一部分,你可以使用像这样的代码:
String inputFilePath1 = @""; //back of page
String inputFilePath2 = @""; //report
String outPutFilePath = @""; //final report
PDFDocument doc1 = new PDFDocument(inputFilePath1);
PDFDocument doc2 = new PDFDocument(inputFilePath2);
// Get a page from the first document. -> back of page
PDFPage page = (PDFPage)doc1.GetPage(0);
for(int i = 1; i <= doc2.PageCount; i++)
{
if (i % 2 == 1)
{
// Insert the page to the second document at specified position.
doc2.InsertPage(page, i);
}
}
// Output the new document.
doc2.Save(outPutFilePath)