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...

--
signature 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.***

<<inline: arsretiaLogo.gif>>

Reply via email to