In my application, i need to read the existing pdf and add barcode to the existing PDF and pass it to output stream. here the existing pdf is like template. I am using iText jar for adding barcode.
I want to know the possibilities of converting PdfStamper
object to byte array or PdfContentByte
to byte array. Can anyone help on this?
Your question is unclear. I assume that you want to write to a
ByteArrayOutputStream
instead of to aFileOutputStream
. There are different examples on how to do that on the iText web site.See for instance the FormServlet example where it says:
Then later in the example, we do this:
If you want a
byte[]
, you can simply do this:I hope your question wasn't about writing a
PdfContentByte
stream to abyte[]
because that wouldn't make sense: a content stream doesn't contain any resources such as fonts, images, form XObjects, etc...