I'm not sure what your problem is but the templates can only be used in the
document where they were created. It's also advisable to use a different
Document for each writer as the direct writing does not support multiple
producers (may work today bit not tomorrow).

Best Regards,
Paulo Soares

> -----Original Message-----
> From: Andrea Franco [SMTP:[EMAIL PROTECTED]
> Sent: Monday, March 17, 2003 18:46
> To:   [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject:      [iText-questions] pdfTemplate copy problem
> 
> Hi everyone,
> 
> I write my text on one or more templates when I find a  specific tag I 
> write all my templates into pdf document.
> 
> The problem is the following...
> when I need to write the same templates on another document I obtain the 
> new pdf document with size to zero.
> 
> below is my code:
> 
> I use this method every time I need to create a new pdf Document
> Only for the first pdf I obtain the right document for the other I don't 
> have anything (only file with size to zero)
> 
>     /**
>      * Creates PDF Document
>      */
>     private void createDocument() throws PDFWriterException {
> 
>             try {
>                 document = new Document(PageSize.A4, 0, 0, 0, 0);
>                 if (sPdfFile.indexOf(".")!=-1)  {
>                     sPdfFile =
> sPdfFile.substring(0,sPdfFile.indexOf("."));
>                 }
>                
>                 String sPdfDoc = sPdfFile + "_" + sPdfsOutputPrefix + 
> "_" + iPdfProgress + ".pdf";
>                 //PdfWriter _writer = PdfWriter.getInstance(document, 
> new FileOutputStream(sPdfDoc));
>                 writer = PdfWriter.getInstance(document, new 
> FileOutputStream(sPdfDoc));
>                 iPdfProgress++;
> 
>                 cb = writer.getDirectContent();
>                 document.open();
>                 copyTemplate();
>             }
>             catch(Exception e) {
>                 e.printStackTrace();
>                 throw new 
> PDFWriterException(PDFWriterException.asMessages[1], e.getCause());
>             }
>     }
> 
> 
> I try to copy previous templates generated with an old PdfContentByte 
> (cb) into a new template ..like below..
> 
>             for (int ndx=0; ndx<vTemplates.size(); ndx ++) { // 
>  vTemplates is a PdfTemplate Vector
>                
>                 PdfTemplate _oTemplate = (PdfTemplate)vTemplates.get(ndx);
>                 //creates nw template with current pdfcontentByte
>                 PdfTemplate _Template = cb.createTemplate(fDocWidth, 
> fDocHeight);
>                 _Template.addTemplate(_oTemplate, 0, 0);
>                _vTemplates.add(_Template); // is my new pdfTemplate vector
>             }
> 
> but the result is equal ...
> 
> Do you know what I wrong or what I don't know ??
> 
> Sorry for my english...
> 
> -- 
> Andrea Franco
> Arsretia S.r.l.
> Via D. Sansotta, 97
> 00144 Roma (IT)
> e-mail: [EMAIL PROTECTED]
> Tel.: +39 06 52 27 00 97
> Fax : +39 06 52 27 23 13
> 
> *** ArsRetia s.r.l.*** << Message: Untitled Attachment >> 


-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open! 
Get cracking and register here for some mind boggling fun and 
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to