This same code works fine in a standalone.

I made some changes for the server app...

try {
                        PdfReader reader = new PdfReader(readPdf);
                        System.out.println("Pdf Version: 
"+reader.getPdfVersion());
                        System.out.println("Num of Pages: "+ 
reader.getNumberOfPages());
                        System.out.println("File Length: 
"+reader.getFileLength());
                        System.out.println("Encrypted: "+reader.isEncrypted());
                        
                        document = new Document();
                        
                        PdfStamper stamper = new PdfStamper(reader, bos);
                        writer = writer.getInstance(document, bos);
                        document.open();
                        
                        AcroFields form = stamper.getAcroFields();
                        form.setField("fullName", "Blackie Lawless");
                        form.setField("representativeName", "Rob Halford");
                        
                        writer = stamper.getWriter();
                        document.close();
                        writer.close();
                        stamper.close();
                        
                        
                        response.setHeader("Expires", "0");
                        response.setHeader("Cache-Control", "must-revalidate, 
post-check=0,
pre-check=0");
                        response.setHeader("Pragma", "public");
                        response.setContentType("application/pdf");
                        ServletOutputStream out = response.getOutputStream();
                        bos.writeTo(out);
                        out.flush();
                } catch (DocumentException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }

I can tell I am reading the file by the println. I still get same error from
before. If I change the line

PdfStamper stamper = new PdfStamper(reader, bos); 
to
PdfStamper stamper = new PdfStamper(reader, new
FileOutputStream(resultPdf));

it will write to the directory. I really need to serve the pdf to the
browser using PdfStamper. Please help, my brain says rage.

Will


1T3XT info wrote:
> 
> wmhfitz wrote:
>> I am getting the following error:
>> 
>> Could not invoke the service() method on servlet clearview. Exception
>> thrown
>> : org.springframework.web.util.NestedServletException: Request processing
>> failed; nested exception is ExceptionConverter: java.io.IOException: The
>> document has no pages.
> 
> Nothing was added to the PDF document upon document.close();
> Most probable cause: something else caused an exception; the exception 
> was caught, all lines adding content were skipped and document.close() 
> was invoked. You should add more debugging to your application.
> -- 
> This answer is provided by 1T3XT BVBA
> http://www.1t3xt.com/ - http://www.1t3xt.info
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> 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
> 
> 

-- 
View this message in context: 
http://www.nabble.com/The-document-has-no-pages.-tp21080269p21086765.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
_______________________________________________
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

Reply via email to