Hello,
 
As far as I understand, the problem you are getting is due to the flatten of 
the fields. I never used it, but it seems to be a good functionality. However, 
if the form script is lost while making the flatten of the fields, then this 
functionality has a great cost, and so, you shouldn´t use it.
 
If I was you I would make this:
 
1 - Extrat the xfa datasets from the pdf (search this forum for an example)
2 - Change this xfa structure, given it the values of each field. This is a 
simple xml manipulation.
3 - inject the xfa dataset into the xfa datastructure of the PDF
4 - Extract the script part of your PDF (it is a part of the xfa sctrucure). To 
make this easier you should put all the code inside functions in a script 
variable while in LiveCycle Designer. Note that if this is a reader extendend 
PDf you will loose the extended functionalities.
5 - Change the code so that when the form will be opened, all the fileds will 
be read only.
6 - An option is to put this function inside the PDf while you are creating it 
in LiveCycle designer.
 
 The result of this is that all the xfa data and xfa structure will be rendered 
by the Reader without any intervention of iText. The script will be executed 
and your fields will be read only. Note that if you open this PDF in a pdf 
reader different from Acrobat Reader, your data will not be merged with the 
fields.
> Date: Fri, 7 Mar 2008 11:49:55 +0000> From: [EMAIL PROTECTED]> To: 
> [email protected]> Subject: Re: [iText-questions] 
> AcroFields - PDFStamper - Problem with Custom Formatting on Fields> > iText 
> doesn't process the PDF Javascript and I don't think that you will> find 
> anything to do it except from Adobe. If you know what the formating> will be 
> you can set the field with the value and what will be actually> displayed, 
> for example:> > form.setField(key, "1234.5", "1,234.50"); > > Paulo> > > 
> -----Original Message-----> > From: [EMAIL PROTECTED] > > [mailto:[EMAIL 
> PROTECTED] On > > Behalf Of binoIchi> > Sent: Friday, March 07, 2008 11:33 
> AM> > To: [email protected]> > Subject: [iText-questions] 
> AcroFields - PDFStamper - Problem > > with Custom Formatting on Fields> > > > 
> > > Hi,> > > > I have read through a lot of posts regarding PDF stamper and > 
> > have not seen a> > post regarding populating fields which contain custom > 
> > formatting. I am not> > sure if I am doing this correctly so some advice or 
> help would be> > appreciated:> > > > Background:> > > > Basically I am trying 
> to stamp a field on a pre-existing PDF > > which contains> > form elements. 
> The form element on the PDF contains some simple custom> > formatting as 
> follows (JavaScript code) - In the Field > > properties of the> > form field 
> the Custom Format Script is as follows:> > > > if (event.value < 0.0) {> > 
> this.getField("sign").value = "-"> > } else {> > this.getField("sign").value 
> = " "> > }> > event.value = util.printf("%,0.2f", Math.abs(event.value));> > 
> > > The purpose of this JavaScript is to format a given number as > > the 
> absolute> > value of the number and populate another field with the sign > > 
> of the number,> > for example, "1234.5" would be displayed as "1,234.50" in 
> the > > main field and> > " " in the sign field and "-1234.5" should be 
> displayed as > > "1,234.50" in the> > main field and "-" in the sign field 
> (it's for a financial based> > application).> > > > iText code:> > > > I load 
> and populate the the pre-formatted PDF as follows, the > > values which> > 
> are to be populated are held in a HasMap (called map):> > > > // Create the 
> stamper> > PdfStamper stamper = new PdfStamper(copyReader, out);> > > > // 
> Get the fields for stamping> > AcroFields form = stamper.getAcroFields();> > 
> form.setGenerateAppearances(true);> > > > // For each field in the map> > for 
> (String key : map.keySet()) {> > > > // Set the value to the PDF> > 
> form.setField(key, map.get(key));> > }> > > > // Flatten the form - this 
> means that only the data is> > displayed, not the form entry fields> > 
> stamper.setFormFlattening(true);> > > > // Close the stamper> > 
> stamper.close();> > > > Problem:> > > > When I open the PDF which is created 
> the custom formatting > > has not been> > applied. Example, if I set the 
> field to a value of "-1234.5" the PDF> > displays "-1234.5" rather than the 
> formatted values > > ("1,234.50" and "-"). I> > have noticed that this is 
> also the case for other fields which use> > "standard" formatting (i.e. not 
> custom formatting). These > > fields also seem> > to show the unformatted 
> value.> > > > Setting the "setFormFlattening(false)" statement displays the 
> values> > correctly on the PDF, however, I require the fields to be > > 
> protected (this is> > a read only version of the document, the users are not 
> > > allowed to update the> > information). I have also been able to set the 
> protected flag on the> > underlying form field, this does not have any effect 
> on the > > outcome (i.e.> > the formatting has not taken place).> > > > Has 
> anyone else seed this problem? I am currently using iText > > version 2.0.7,> 
> > and viewing the PDFs using Acrobat Reader 8.1> > > > Thanks,> > > > Bino> > 
> > Aviso Legal:> > Esta mensagem é destinada exclusivamente ao destinatário. 
> Pode conter informação confidencial ou legalmente protegida. A incorrecta 
> transmissão desta mensagem não significa a perca de confidencialidade. Se 
> esta mensagem for recebida por engano, por favor envie-a de volta para o 
> remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa 
> que não o destinatário de usar, revelar ou distribuir qualquer parte desta 
> mensagem. > > > > Disclaimer:> > This message is destined exclusively to the 
> intended receiver. It may contain confidential or legally protected 
> information. The incorrect transmission of this message does not mean the 
> loss of its confidentiality. If this message is received by mistake, please 
> send it back to the sender and delete it from your system immediately. It is 
> forbidden to any person who is not the intended receiver to use, distribute 
> or copy any part of this message.> > > 
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to