I am adding a text to the existing pdf and writing to bytearray output stream but when I open the "HelloWorld2.pdf", text is not showing up? But if i create a new pdf for e.g. HelloWorldNew.pdf then the text is shwoing up.
Can any one help me to find out the error reg bytearray outputstream.?
PdfReader pdfReader = new PdfReader(
"C:\\POC\\HelloWorld2.pdf");
ByteArrayOutputStream bao = new ByteArrayOutputStream();
PdfStamper pdfStamper = new PdfStamper(pdfReader, bao);
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat f = new SimpleDateFormat("MM/dd/yyyy");
String signatureDate = f.format(currentDate.getTime());
I am not saving boa object , I am thinking PdfStamper pdfStamper = new PdfStamper(pdfReader,bao) will automatically takes care of that.
Can you tell me wts the code I need to add in order to get the text in same Pdf instaed of careting new one.
Thanks
Suguna Devarla
Greenhorn
Joined: Jan 11, 2008
Posts: 11
posted
0
I have added below code but still no luck..Can any one explain how to add content to exisitng pdf with out creating a new different physical file
I wanted to see the new content in same "HelloWorld2.pdf"
PdfReader pdfReader = new PdfReader(
"C:\\POC\\HelloWorld2.pdf");
ByteArrayOutputStream bao = new ByteArrayOutputStream();
PdfStamper pdfStamper = new PdfStamper(pdfReader, bao);
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat f = new SimpleDateFormat("MM/dd/yyyy");
String signatureDate = f.format(currentDate.getTime());
Here is the exception.. any reply would be a big help.
java.io.IOException: PDF header signature not found.
at com.lowagie.text.pdf.PRTokeniser.checkPdfHeader(PRTokeniser.java:204)