Thanks Mark for your help . I figured out the problem. The PDF was generated
but at incorrect location, since I was using wrong variable to create
outputstream.


Mark Storer-2 wrote:
> 
> Nothing is jumping out at me.  What is the output from all those
> system.out.println calls?
> 
> By the way, two suggestions.
> 1) Use spaces instead of tabs.  Most editors will let you control how many
> spaces each tab is converted to.  Your code formatting looks BIZARRE to me
> in my email program because it's definition of a tab differs from yours. 
> That's pretty much a given.
> 2) Your debug output would be more useful if you described what was
> happening rather than simply writing out sequential numbers.  For example
> you could replace:
> 
> System.out.println("Test-5");
> 
> with
> 
> System.out.println( "total pages: " + totalPages );
> 
> 
> 
> --Mark Storer 
>   Senior Software Engineer 
>   Cardiff.com
> 
> #include <disclaimer> 
> typedef std::Disclaimer<Cardiff> DisCard; 
> 
> 
> 
>> -----Original Message-----
>> From: xdmello [mailto:xdme...@gmail.com]
>> Sent: Wednesday, September 16, 2009 6:20 PM
>> To: itext-questions@lists.sourceforge.net
>> Subject: [iText-questions] Split PDF usinh Itext
>> 
>> 
>> 
>> I am using below code to split PDf. It compiles fine.But 
>> there is no PDf
>> generated generated at the mentioned location. I am using 
>> this function in
>> servlet. am I missing something.
>> 
>> public  void splitPDF(String inputflname,String imagename,String
>> outfilename) 
>> { 
>>  
>>         System.out.println("Split PDF file");
>>              File baseDir = new File(path);
>>              File ipfile = new File(baseDir, "WEB-INF/out/"  + inputflname);
>>         File imgfile = new File(baseDir, "WEB-INF/out/" + imagename);
>>         File otfile = new File(baseDir, "WEB-INF/out/" + outfilename);
>>              System.out.println("Test-1");
>>              Document document = new Document(); 
>>              int  fromPage =1;
>>              System.out.println("Test-2");
>>        try { 
>>            System.out.println("Test-3");
>>                        InputStream  inputStream =  new 
>> FileInputStream(ipfile);
>>                    InputStream  imageStream =  new FileInputStream(imgfile);
>>                    OutputStream  outputStream= new 
>> FileOutputStream(outfilename);    
>>                        System.out.println("Test-4");
>>                        
>>              PdfReader inputPDF = new PdfReader(inputStream); 
>>                              PdfReader imagePDF = new PdfReader(imageStream);
>>                 int totalPages = inputPDF.getNumberOfPages(); 
>>                              System.out.println("Test-5");
>>                 
>>                 PdfWriter writer = PdfWriter.getInstance(document,
>> outputStream); 
>>                 document.open();       
>>                 PdfContentByte cb = writer.getDirectContent(); 
>>                 PdfImportedPage page;
>>                              System.out.println("Test-6");
>>                 while(fromPage <= totalPages) 
>>                 { 
>>                        System.out.println("Test-7");
>>                                         document.newPage();      
>>                                         page = 
>> writer.getImportedPage(imagePDF, 1); 
>>                        cb.addTemplate(page, 0, 0);
>>                                         System.out.println("Test-8");
>>                        page = writer.getImportedPage(inputPDF, fromPage); 
>>                        cb.addTemplate(page, 0, 0);
>>                                         System.out.println("Test-9");
>>                        fromPage++;        
>>                 } 
>>                              System.out.println("Test-10");
>>                 document.close(); 
>>                 outputStream.close();
>>                              System.out.println("Test-11");
>>                        
>>             }
>>                      catch (Exception e) 
>>             { 
>>               System.out.println("Test-12");
>>                        e.printStackTrace(); 
>>             }
>> }
>> -- 
>> View this message in context: 
> http://www.nabble.com/Split-PDF-usinh-Itext-tp25483687p25483687.html
> Sent from the iText - General mailing list archive at Nabble.com.
> 
> 
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay 
> ahead of the curve. Join us from November 9&#45;12, 2009. Register
> now&#33;
> http://p.sf.net/sfu/devconf
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> Check the site with examples before you ask questions:
> http://www.1t3xt.info/examples/
> You can also search the keywords list:
> http://1t3xt.info/tutorials/keywords/
> 
> 
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay 
> ahead of the curve. Join us from November 9&#45;12, 2009. Register
> now&#33;
> http://p.sf.net/sfu/devconf
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> Check the site with examples before you ask questions:
> http://www.1t3xt.info/examples/
> You can also search the keywords list:
> http://1t3xt.info/tutorials/keywords/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Split-PDF-usinh-Itext-tp25483687p25496461.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to