Adding a pdf footer conditionally on certain pages

2019-09-16 15:11发布

问题:

I have one web application which generates pdfs for each request.The data would be different in these pdfs based on user information.The number of pages can vary from 6 to 9.To construct the pdfs,i have multiple PdfPTables and each table has its own cells.Once i construct all the PdfPTables,as a final step i am adding the tables to the document.

Recently i have a requirement as,when ever there is a particular text then we need to add the footer to indicate the occurrence of this text in the respective pages.This can in 3 page or this can be 6 page or in both.I was thinking to figure out a way for this.

One of the approach i have is to identify this text at the time of adding to the PdfPCell and then generate a footer.But at this stage i dont have an idea as which page this would be in the document.I am letting the table to grow to the next page if it doesn't fit to the current page.

Another approach is to parse the entire pdf before sending the response back.Take one by one page,get the text and compare against the search text and if exists add a footer.Some how i feel this is a costly operation.

Please let me know if any of you have any suggestion to this. Any help would be highly appreciated.

Thanks,