Reputation: 90
I have a method that creates a pdf file from a database, each page having information from a record of database. I use a pdfWriter object to create the file.
Can I copy each page from pdfWriter after the page is created in my method and write the page in another separate pdf file? The result will be like splitting the pdf file.
Upvotes: 0
Views: 660
Reputation: 96039
Can I copy each page from pdfWriter after the page is created in my method and write the page in another separate pdf file? The result will be like splitting the pdf file.
No.
The PdfWriter
is not accumulating everything you add to it, it writes out the data as early as possible to its output stream. So it quite likely does never even contain a whole page you want to get from it.
Furthermore, it does not have methods to allow such content retrievable. PdfWriter
is designed as a data-sink only, not a data source.
But you can read the output of the writer using a new PdfReader
instance and copy pages from there.
Upvotes: 2