Diptiman Prusty wrote:
> Hi
> I am reading a PDF form template and then creating a pdfstamper to
> fill up some fields and save it to a new file.
> Then I want to read the updated file and send it to browser. The updated
> file is created and when opened in acrobat reader shows filled up
> values. But if I pass the same file to browser through servletoutput
> stream it doesnt show filled up values.
>
> Here is my code :
> PdfReader reader1 = new PdfReader("sampleReport.pdf");
> FileOutputStream fOut = new FileOutputStream("updatedForm.pdf");
> PdfStamper stamper1 = new PdfStamper(reader1,fOut);
> AcroFields form2 = stamper1.getAcroFields();
> form2.setField("Name", "Diptiman","Diptiman");
> stamper1.close();
>
> TIll her it works and new file is saved.
>
> PdfReader reader = new PdfReader("updatedForm.pdf");
> ByteArrayOutputStream baos = new ByteArrayOutputStream();
> PdfStamper stamper = new PdfStamper(reader, baos);
> stamper.close();
>
> ServletOutputStream out = response.getOutputStream();
> response.setHeader("Content-Disposition:",
> "inline;filename=updatedForm.pdf" );
> response.setHeader("Expires", "0");
> response.setHeader("Cache-Control","must-revalidate,
> post-check=0, pre-check=0");
> response.setHeader("Pragma", "public");
> response.setContentType("application/pdf");
> response.setContentLength(baos.size());
> baos.writeTo(out);
> out.flush();
>
> What am I doing wrong here?
There is no reason to save the PDF locally (unless you did it for
testing purposes); there is no reason why the PDF shouldn't show up
in the client's browser unless you're not telling us everything.
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php