public class FormPdfView extends AbstractPdfView {

        protected void buildPdfDocument(Map model, Document document, PdfWriter
writer, HttpServletRequest request,
                        HttpServletResponse response) throws ServletException, 
IOException {
                
                PdfFormModel pdfFormModel = (PdfFormModel) 
model.get("pdfFormModel");
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                String readPdf =
"C:\\TRMWorkspace\\ClearView\\WebContent\\WEB-INF\\resources\\forms\\CAI0708.pdf";
                String result =
"C:\\TRMWorkspace\\ClearView\\WebContent\\WEB-INF\\resources\\forms\\ENABLED_CAI.07.10.08.pdf";
                
                System.err.println("1");
                try {
                        PdfReader reader = new PdfReader(readPdf);
                        System.err.println("Pdf Version: 
"+reader.getPdfVersion());
                        System.err.println("Num of Pages: "+ 
reader.getNumberOfPages());
                        System.err.println("File Length: 
"+reader.getFileLength());
                        System.err.println("Encrypted: "+reader.isEncrypted());
                        
                        document = new Document();
                        System.err.println("2");
                        PdfStamper stamper = new PdfStamper(reader, bos);
                        System.err.println("3");
                        document.open();
                        System.err.println("4");
                        AcroFields form = stamper.getAcroFields();
                        System.err.println("5");
                        form.setField("fullName", "Blackie Lawless");
                        System.err.println("6");
                        form.setField("representativeName", "Rob Halford");
                        System.err.println("7");
                        
                        document.close();
                        System.err.println("8");
                        stamper.close();
                        System.err.println("9");
                                        
                        response.setHeader("Expires", "0");
                        System.err.println("10");
                        response.setHeader("Cache-Control", "must-revalidate, 
post-check=0,
pre-check=0");
                        System.err.println("11");
                        response.setHeader("Pragma", "public");
                        System.err.println("12");
                        response.setContentType("application/pdf");
                        System.err.println("13");

                } catch (DocumentException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
        }
}

I put in the printlns...

[12/19/08 10:52:48:720 CST] 00000063 SystemErr     R 1
[12/19/08 10:52:48:955 CST] 00000063 SystemErr     R Pdf Version: 6
[12/19/08 10:52:48:955 CST] 00000063 SystemErr     R Num of Pages: 2
[12/19/08 10:52:48:955 CST] 00000063 SystemErr     R File Length: 418076
[12/19/08 10:52:48:955 CST] 00000063 SystemErr     R Encrypted: false
[12/19/08 10:52:48:955 CST] 00000063 SystemErr     R 2
[12/19/08 10:52:49:001 CST] 00000063 SystemErr     R 3
[12/19/08 10:52:49:001 CST] 00000063 SystemErr     R 4
[12/19/08 10:52:49:064 CST] 00000063 SystemErr     R 5
[12/19/08 10:52:49:314 CST] 00000063 SystemErr     R 6
[12/19/08 10:52:49:314 CST] 00000063 SystemErr     R 7
[12/19/08 10:52:49:314 CST] 00000063 SystemErr     R 8
[12/19/08 10:52:49:470 CST] 00000063 SystemErr     R 9
[12/19/08 10:52:49:470 CST] 00000063 SystemErr     R 10
[12/19/08 10:52:49:470 CST] 00000063 SystemErr     R 11
[12/19/08 10:52:49:470 CST] 00000063 SystemErr     R 12
[12/19/08 10:52:49:470 CST] 00000063 SystemErr     R 13
[12/19/08 10:52:49:470 CST] 00000063 ServletWrappe E   SRVE0068E: 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.
        at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:583)
        at
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
        at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1572)
        at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:762)
        at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3146)
        at 
com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:250)
        at 
com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:212)
        at
com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1958)
        at
com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:112)
        at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:472)
        at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:411)
        at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:288)
        at
com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminaters(NewConnectionInitialReadCallback.java:207)
        at
com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:109)
        at
com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:566)
        at
com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:619)
        at
com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:952)
        at
com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1039)
        at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
Caused by: ExceptionConverter: java.io.IOException: The document has no
pages.

I don't think any lines are being skipped.



1T3XT info wrote:
> 
> wmhfitz wrote:
>> Instead of saying "it's bound to fail" do you have any real suggestions
>> of
>> what is I need to change to accomplish this?
> 
> The old fashioned way would be to add
> System.err.println("I'm here 1");
> System.err.println("I'm here 2");
> System.err.println("I'm here 3");
> ...
> between every line of code you have written.
> I'm 99% sure some of the lines are skipped.
> -- 
> 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.-tp21080269p21094585.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