Paulo, no need to. 
Thanks to your answer (and due to my ignorance) know I think I have it.
I am doing some more tests, but I think I see the light know.......



On [DATE], "[NAME]" <[ADDRESS]> wrote:

> Paulo, first of all, thanks
> Knowing that your time is money, can you be more specific?
> 
> 
> 
> On [DATE], "[NAME]" <[ADDRESS]> wrote:
> 
>> PdfCopy doesn't handle fields, use PdfCopyFields.
>> 
>> Paulo
>> 
>> ----- Original Message -----
>> From: "David Ricardo Lopez Bonaechea" <[EMAIL PROTECTED]>
>> To: <[EMAIL PROTECTED]>
>> Sent: Tuesday, September 09, 2008 10:45 AM
>> Subject: [iText-questions] Problem duplicating PDF page. Using PdfCopy
>> andgetImportedPage
>> 
>> 
>> Hello to all.
>> 
>> I am having problems to implement in Java, the PDF Generation we run on PC¹s
>> with a Delphi app.
>> 
>> I find iText very handy, but I ran into a problem, that after 3 days, is
>> driving me crazy.
>> 
>> We have PDF ³templates² that are stored on the server. These are retrieved
>> by the PC and then using, Gnostice VCL Delhpi Component forms are inserted
>> with values, after duplicating the template page if necessary. Also, we
>> rename some fields on the original form.
>> I tried to emulate this logic with itext, but I ran into some problems.
>> Using the next code:
>>             String plantilla = ³/tmp2/ PDFSO15732R.pdf²;
>>           Document document = new Document();            PdfCopy copy = new
>> PdfCopy(document, new FileOutputStream(
>> "/tmp2/salida.pdf"));            document.open();            reader = new
>> PdfReader(plantilla);            baos = new ByteArrayOutputStream();
>> stamper = new PdfStamper(reader, baos);
>> stamper.setFormFlattening(false);            AcroFields form =
>> stamper.getAcroFields();            form.renameField("Pagina","cambiado
>> "+i);            form.setField("Cliente", "David");
>> stamper.close();            baos.flush();            reader = new
>> PdfReader(baos.toByteArray());            PdfImportedPage pagina_a_copiar =
>> copy.getImportedPage(reader, 1);            copy.addPage(pagina_a_copiar);
>>             copy.addPage(pagina_a_copiar);
>>            copy.addPage(pagina_a_copiar);
>> 
>> The generated file salida.pdf looks fine.
>> 
>> Whenever I try to do a loop for this, like:
>>            ByteArrayOutputStream baos;            PdfReader reader;
>> PdfStamper stamper;            Document document = new Document();
>> PdfCopy copy = new PdfCopy(document, new
>> FileOutputStream(                    "/tmp2/salida.pdf"));
>> document.open();            for (int i = 0; i < 3; i++) {
>> reader = new PdfReader(plantilla);                baos = new
>> ByteArrayOutputStream();                stamper = new PdfStamper(reader,
>> baos);                stamper.setFormFlattening(false);
>> AcroFields form = stamper.getAcroFields();
>> form.renameField("Pagina","cambiado "+i);
>> form.setField("Cliente", "David");                stamper.close();
>> copy.addPage(copy.getImportedPage(reader, 1));
>>     copy.flush();            }            document.close();
>> 
>> The first page is OK, but pages 2 and 3 are wrong. Also, the renamefield
>> works, but the setField sets the value (as I have seen from the step-by-step
>> debug) but the value is not there on the final output.I have downloaded the
>> iText source code, but I am unable to find where it is going wrong.
>> If I set the flatten to true, the result is even worst.
>> Maybe it is the template, but I have to find the way to overcome this, since
>> I cannot change the templates.
>> 
>> Also, if a open a PdfStamper on the generated pdf file (salida.pdf) and try
>> to retreive the AcroFields, the list is empty. This would not be a problem
>> If I could do the set Value on the loop itself, and the to add the fial
>> page. This is also not working, with the same problem above.
>> 
>> I have attached the template and output.
>> 
>> Thanks in advance for any help that an be provided.
>> 
>> Best regards, David
>> 
>> 
>> 
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>> Build the coolest Linux based applications with Moblin SDK & win great prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> iText-questions mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/itext-questions
>> 
>> Buy the iText book: http://www.1t3xt.com/docs/book.php
>> 



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to