Hi Bruno,
 
You are right, I got it now.
 
I have one more issue in the same context.
Pls look in to the below code where i am converting a page as PdfTemplate and adding it to the original pdf at some location.
 
i have a problem in setting the page as template to the pdfcontentbyte (  cb.addTemplate(page2, 0,-100 );  ),
as i am getting the y-co-ordinate of the last row of the table displayed dynamically, i want to use this to position the table, but when i use this ,its overlapping with the table. when i give the y-cordinate as -100 ,its positioning correctly after the table. i am not able to understand the reason for this. do you have any clue regarding this ???
 
 
public void renderFinalDocument(String inputFileName, String outputFileName) throws Exception{
     PdfReader reader = new PdfReader(inputFileName);
        System.out.println( "No of Pages to be rendered --> "+  reader.getNumberOfPages() );
  FileOutputStream out = new FileOutputStream(outputFileName);
 
  Rectangle psize = reader.getPageSize(1);
 
  Document document = new Document(psize);
        PdfWriter writer = PdfWriter.getInstance(document, out);
 
        document.open();
 
        PdfContentByte cb = writer.getDirectContent();
        PdfImportedPage page1 = writer.getImportedPage(reader, 1);
        PdfImportedPage page2 = writer.getImportedPage(reader, 2);
 
        cb.addTemplate(page1, 0, 0);
        //Add a new Page for the original PDF (so that we can test Table creation)
     //   document.newPage();
        float y = populateTableElements(cb, 10, 450);
 
        //----------------------------------------------------
        //FIXME:
        //At this point we need to check if everything fits in one page..
        // There is a method to do this..
        //----------------------------------------------------
 
        System.out.println("Y Coordinate of Table elements = "+y);
 
        Rectangle boundingBox = page1.getBoundingBox();
        System.out.println("Height of Page = "+ boundingBox.height());
 
        //FIXME: Need to translate this Y-coordinate using the TLM (as in PDF Spec.) using Affine Transform
       
        //Add a new Page for the original PDF (so that we can test Table creation)
     //   document.newPage();
        cb.addTemplate(page2, 0,-100 ); 

        document.close();
 }
 
 
Thanks in advance
Krishna Kishore
 
----- Original Message -----
From: "Bruno Lowagie" <[EMAIL PROTECTED]>
To: "Krishna Kishore .J" <[EMAIL PROTECTED]>
Cc: <itext-questions@lists.sourceforge.net>
Sent: Tuesday, July 12, 2005 11:56 AM
Subject: Re: [iText-questions] Can i create a pdf template for a pdf and add it to another pdf ???

> I think the original answer was right, but maybe you interpreted it wrong.
> When you say PDF template. Do you mean a separate PDF document?
> Because the person who answered your question was talking about the
> iText object PdfTemplate, not about a separate file.
> One of the subclasses of PdfTemplate, is PdfImportedPage.
> See
http://itextdocs.lowagie.com/tutorial/general/copystamp/
>
> Krishna Kishore .J wrote:
>
> >Hi,
> >Thanks for your reply.
> >
> >Can i create a pdf template for a pdf and add it to another pdf ???
> >
> >My problem is :
> >I have a pdf template with the following:
> >
> >1. Some content,form fields followed by
> >2. dynamic table which again followed by
> >3. text and form fields.
> >
> >I am able to do 1,2 above ,but am facing problem in doing the 3rd one.
> >I have the following options as of now:
> >
> >a. Hard code the text etc which are after the table as i know the
> >co-ordinates after the table. but this will be pdf specific, i am trying for
> >a more generalized one.
> >b. try to put the content after the table in a different pdf template or a
> >new page in the same template, but i dont know how to create a pdf template
> >for a pdf and add it to existing one.
> >
> >can any one help me out.
> >
> >pls point me to some examples which will guide me.
> >

Reply via email to