I believe the correct answer is that with templates you usually want to place text and/or other content at precise locations so that you do not interfere visually with the template's content. Thus one would commonly use the low-level PdfContentByte functionality to, for example, add text (data) in blanks on a PDF that represents a printed form (not an actual "PDF form"). I don't see any reason that you *couldn't* use the Document approach, however, so how you PROBABLY would want to do it:
-create your Document and PdfWriter as usual -keep a reference to your PdfWriter -use Document APIs as usual, including newPage() -use low-level APIs esp. PdfContentByte to add the template content to your PdfContentByte--the trick is that you will need to get the PdfContentByte for each page using PdfWriter.getDirectContent() or, more likely, getDirectContentUnder(). Again, I am not sure you can get the results you desire from mixing approaches this way, but there's my take on how you would go about it regardless. This is untested, but I do hope it helps. -Matt --- Tim Wilkins <[EMAIL PROTECTED]> wrote: > Hello all, > > I was just wondering if some kind sole could clarify > the current state > of using pre-existing pdf files as templates for > creating new pdf files. > > I know that it is possible to grab pages out of > existing pdf files and > insert them into a new pdf document. I also know > that you can add > content to these copied pages by using the methods > in the PdfContentByte > class. However the methods in the PdfContentByte > seem quite low level > and don't appear (I might be wrong) to offer the > same level of > functionality as the 'add()' method of the Document > class. > > I was hoping to be able to create a Document > instance and add content to > it in the usual way. Then to position this new > Document over the top of > a template page from an existing pdf document so > that it would appear as > a new pre-formated page. > > I was hoping to find a method with the following > signature > PdfContentByte.addTemplate(Document,posX,posY) but > unfortunately it does > not exist. I then tried mucking around trying to > convert the Document > object to a PdfTemplate object but with no luck. > > So to summaries: > > 1. Is there a way of placing a Document over the > top of an exiting > page template? > 2. Is there an easier way of implementing what > I'm trying to achieve? > > > Any help on this matter will be much appreciated, > > Cheers, > > Tim Wilkins > > -- > Senior Technical Developer > MediaTel Group > 84-86 Regent Street > London > W1B 5AJ > > 020 7439 7575 > 020 7734 0940 > > www.MediaTelINSIGHT.co.uk has been relaunched with > new content and improved functionality. > > Our INSIGHT Saves You Time... > > > This message is for the named recipient's use only > and may contain confidential or privileged > information. If you receive this message in error, > please immediately delete it and all copies of it > from your system, destroy any hard copies of it and > notify the sender. You must not, directly or > indirectly, use, disclose, distribute, print, or > copy any part of this message if you are not the > intended recipient. Email communications are not > secure and therefore the MediaTel Group does not > accept liability for any errors or omissions in the > contents of this message which arise as a result of > email transmission. MediaTel reserves the right to > monitor all email communications through its > networks. Any views expressed by an individual in > this email do not necessarily reflect the views of > the MediaTel Group. > > > > > ------------------------------------------------------- > SF.Net email is sponsored by Shop4tech.com-Lowest > price on Blank Media > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R > for only $33 > Save 50% off Retail on Ink & Toner - Free Shipping > and Free Gift. > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > _______________________________________________ > iText-questions mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/itext-questions > __________________________________ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions
