Discussion:
[itextsharp-questions] How to Maintain Textfield Property formating.
Trainwreck
2008-06-12 20:59:48 UTC
Permalink
I have two numeric fields on a single page PDF. One is formatted with a
pre-pending Dollar sign, the other is formatted as a percent.

When I apply the data via AcroFields.SetField(dollarNum, numValue); All
formatting is lost. ie...no dollar sign, no decimal places, no
percents...date format wrong.

How do I maintain all formatting that exist on a current .pdf
template..dates, number formatting like decimal places etc, ?

Thanks in advance for any/all help.
--
View this message in context: http://www.nabble.com/How-to-Maintain-Textfield-Property-formating.-tp17809568p17809568.html
Sent from the itextsharp-questions mailing list archive at Nabble.com.
Paulo Soares
2008-06-12 21:30:05 UTC
Permalink
Only Acrobat can do it. The formatting is done with Javascript and nobody
else supports it. If you know what the formatting is use the SetField()
version with 3 arguments.

Paulo

----- Original Message -----
From: "Trainwreck" <***@e-surety.net>
To: <itextsharp-***@lists.sourceforge.net>
Sent: Thursday, June 12, 2008 9:59 PM
Subject: [itextsharp-questions] How to Maintain Textfield Property
formating.
Post by Trainwreck
I have two numeric fields on a single page PDF. One is formatted with a
pre-pending Dollar sign, the other is formatted as a percent.
When I apply the data via AcroFields.SetField(dollarNum, numValue); All
formatting is lost. ie...no dollar sign, no decimal places, no
percents...date format wrong.
How do I maintain all formatting that exist on a current .pdf
template..dates, number formatting like decimal places etc, ?
Thanks in advance for any/all help.
Trainwreck
2008-06-12 23:02:46 UTC
Permalink
Thanks for the reply. There's no way to gain access to the javascript then?
ActivePDF seems to 'be ok' passing in data and leaving it's format
'un-molested/as requested', I'm wondering 'how'(?).

I've searched the iNet looking for examples of SetField() and it's
properties to no avail. just finding the simple examples
(setfield("pdfField", pdfFielValue)). Meaning I really have no idea 'how' to
put something in the third field that relates to the desired formatting
(setfield("pdfField", pdfFielValue, "whatWouldILookLike")).

Still, this solution is roundabout for me as I never really know 'what'
fields will have special formatting.

Again, thank you for your time.
Post by Paulo Soares
Only Acrobat can do it. The formatting is done with Javascript and nobody
else supports it. If you know what the formatting is use the SetField()
version with 3 arguments.
Paulo
----- Original Message -----
Sent: Thursday, June 12, 2008 9:59 PM
Subject: [itextsharp-questions] How to Maintain Textfield Property
formating.
Post by Trainwreck
I have two numeric fields on a single page PDF. One is formatted with a
pre-pending Dollar sign, the other is formatted as a percent.
When I apply the data via AcroFields.SetField(dollarNum, numValue); All
formatting is lost. ie...no dollar sign, no decimal places, no
percents...date format wrong.
How do I maintain all formatting that exist on a current .pdf
template..dates, number formatting like decimal places etc, ?
Thanks in advance for any/all help.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
itextsharp-questions mailing list
https://lists.sourceforge.net/lists/listinfo/itextsharp-questions
--
View this message in context: http://www.nabble.com/How-to-Maintain-Textfield-Property-formating.-tp17809568p17811622.html
Sent from the itextsharp-questions mailing list archive at Nabble.com.
CodeGreen
2008-06-13 01:23:38 UTC
Permalink
Hello,

I am working with 'TrainWreck' on this issue. I notice that if I use
'FormFlattening = False', and then modify the value (that was input using my
SetField call) of the field in AcrobatReader, then press Enter, the
formatting is applied. So it seems the formatting information is still
contained in the document, is there no way to 'trigger' it the same way that
happens when you hit enter in Reader so that the formatting is applied?

Any help would be very much appreciated!
Thanks!
CodeGreen
--
View this message in context: http://www.nabble.com/How-to-Maintain-Textfield-Property-formating.-tp17809568p17813131.html
Sent from the itextsharp-questions mailing list archive at Nabble.com.
Paulo Soares
2008-06-13 04:58:12 UTC
Permalink
iText doesn't have a Javascript engine, it can't do formating. If you knows
what the field is supposed to look like:

SetField("name", "34", "$34.00")

Paulo

----- Original Message -----
From: "CodeGreen" <***@thegreenhand.com>
To: <itextsharp-***@lists.sourceforge.net>
Sent: Friday, June 13, 2008 2:23 AM
Subject: Re: [itextsharp-questions] How to Maintain Textfield Property
formating.
Post by CodeGreen
Hello,
I am working with 'TrainWreck' on this issue. I notice that if I use
'FormFlattening = False', and then modify the value (that was input using my
SetField call) of the field in AcrobatReader, then press Enter, the
formatting is applied. So it seems the formatting information is still
contained in the document, is there no way to 'trigger' it the same way that
happens when you hit enter in Reader so that the formatting is applied?
Any help would be very much appreciated!
Thanks!
CodeGreen
CodeGreen
2008-06-13 11:49:34 UTC
Permalink
Hello,

Please forgive my persistance, and thank you very much for taking the time
to help. Before giving up on this I just want to make completely sure I am
asking the right question. At my recommendation we have invested time in
replacing an old version (from about 5 years ago) of the commercial product
ActivePDF with the iTextSharp library. I wanted our app to be fully .NET,
and we are interested in implementing Digital Signatures. To upgrade the
ActivePDF was going to be very expensive, so I decided to go with
iTextSharp. Our application uses template PDF Forms created by our
customers. They use Adobe Professional to lay out the forms, putting down
fields named to match database fields. They use the field property
formatting dialog to apply the desired formatting to these fields, date,
currency, decimal position, etc. Our app then looks up the values in the
database and populates these fields. Using the old ActivePDF, if we set
.DoFormFormatting = True, the resulting PDF has the desired formatting
applied. As this functionality is critical to our application, I just want
to be sure that there is no way to accomplish this with iText. As you can
see, in our code there is no way to know the formatting as it is up to the
user to decide, unless we can read it somehow from the properties? Even
then, it seems like it would be very difficult to account for all of the
various options presented in the Acrobat Pro dialog.

Thank you again for all of your help,
CodeGreen
Post by Paulo Soares
iText doesn't have a Javascript engine, it can't do formating. If you knows
SetField("name", "34", "$34.00")
Paulo
--
View this message in context: http://www.nabble.com/How-to-Maintain-Textfield-Property-formating.-tp17809568p17821668.html
Sent from the itextsharp-questions mailing list archive at Nabble.com.
Paulo Soares
2008-06-13 12:49:11 UTC
Permalink
I doubt that they have a full Javascript parser, however it's possible to do
it with the standard formating functions. The functions have the form:

AFNumber_Format(2, 0, 0, 0, "", false);
AFPercent_Format(2, 0);
AFDate_FormatEx("m/d/yy");
AFTime_Format(0);
AFSpecial_Format(3);

If they are not custom functions, it's doable. Look at the Javascript in the
annotation dictionary at /AA-/F-/JS. It's something interesting as a future
development to the library.

Paulo

----- Original Message -----
From: "CodeGreen" <***@thegreenhand.com>
To: <itextsharp-***@lists.sourceforge.net>
Sent: Friday, June 13, 2008 12:49 PM
Subject: Re: [itextsharp-questions] How to Maintain Textfield Property
formating.
Post by CodeGreen
Hello,
Please forgive my persistance, and thank you very much for taking the time
to help. Before giving up on this I just want to make completely sure I am
asking the right question. At my recommendation we have invested time in
replacing an old version (from about 5 years ago) of the commercial product
ActivePDF with the iTextSharp library. I wanted our app to be fully .NET,
and we are interested in implementing Digital Signatures. To upgrade the
ActivePDF was going to be very expensive, so I decided to go with
iTextSharp. Our application uses template PDF Forms created by our
customers. They use Adobe Professional to lay out the forms, putting down
fields named to match database fields. They use the field property
formatting dialog to apply the desired formatting to these fields, date,
currency, decimal position, etc. Our app then looks up the values in the
database and populates these fields. Using the old ActivePDF, if we set
.DoFormFormatting = True, the resulting PDF has the desired formatting
applied. As this functionality is critical to our application, I just want
to be sure that there is no way to accomplish this with iText. As you can
see, in our code there is no way to know the formatting as it is up to the
user to decide, unless we can read it somehow from the properties? Even
then, it seems like it would be very difficult to account for all of the
various options presented in the Acrobat Pro dialog.
Thank you again for all of your help,
CodeGreen
Post by Paulo Soares
iText doesn't have a Javascript engine, it can't do formating. If you knows
SetField("name", "34", "$34.00")
Paulo
CodeGreen
2008-06-13 15:29:43 UTC
Permalink
Cool, so in theory, I should be able to find these javascript calls in the
dictionary (more on that in a second), load aform.js into the .net
javascript engine so I have the standard functions, then execute the calls I
read from the form using the engine, then set the display with the output?

To find the javaScript, I am using this code:

AcroFields acFields = iTStamper.AcroFields;
AcroFields.Item itm = acFields.GetFieldItem("BverPenalty");
PdfDictionary main = (PdfDictionary)itm.merged[0];
PdfDictionary aa = (PdfDictionary)main.Get(PdfName.AA);
foreach (System.Collections.DictionaryEntry item in aa)
{
string val = item.Value.ToString();
string name = item.Key.ToString();
System.Diagnostics.Debug.WriteLine(name + ": " + val);
}

but this is the output

/F: 76 0 R
/K: 77 0 R

I do not see how to drill down further to get javaScript.

Thanks!
Post by Paulo Soares
I doubt that they have a full Javascript parser, however it's possible to do
AFNumber_Format(2, 0, 0, 0, "", false);
AFPercent_Format(2, 0);
AFDate_FormatEx("m/d/yy");
AFTime_Format(0);
AFSpecial_Format(3);
If they are not custom functions, it's doable. Look at the Javascript in the
annotation dictionary at /AA-/F-/JS. It's something interesting as a future
development to the library.
Paulo
--
View this message in context: http://www.nabble.com/How-to-Maintain-Textfield-Property-formating.-tp17809568p17826046.html
Sent from the itextsharp-questions mailing list archive at Nabble.com.
Paulo Soares
2008-06-13 16:34:06 UTC
Permalink
Those are indirect references to an object, in this case a dictionary. Use
PdfReader.GetPdfObject() to resolve the object. Note that legally you can't
use aform.js without Adobe's authorization and I suspect that the Javascript
engine would have to be modified to support the PDF objects.

Paulo

----- Original Message -----
From: "CodeGreen" <***@thegreenhand.com>
To: <itextsharp-***@lists.sourceforge.net>
Sent: Friday, June 13, 2008 4:29 PM
Subject: Re: [itextsharp-questions] How to Maintain Textfield Property
formating.
Post by CodeGreen
Cool, so in theory, I should be able to find these javascript calls in the
dictionary (more on that in a second), load aform.js into the .net
javascript engine so I have the standard functions, then execute the calls I
read from the form using the engine, then set the display with the output?
AcroFields acFields = iTStamper.AcroFields;
AcroFields.Item itm = acFields.GetFieldItem("BverPenalty");
PdfDictionary main = (PdfDictionary)itm.merged[0];
PdfDictionary aa = (PdfDictionary)main.Get(PdfName.AA);
foreach (System.Collections.DictionaryEntry item in aa)
{
string val = item.Value.ToString();
string name = item.Key.ToString();
System.Diagnostics.Debug.WriteLine(name + ": " + val);
}
but this is the output
/F: 76 0 R
/K: 77 0 R
I do not see how to drill down further to get javaScript.
Thanks!
Post by Paulo Soares
I doubt that they have a full Javascript parser, however it's possible to do
AFNumber_Format(2, 0, 0, 0, "", false);
AFPercent_Format(2, 0);
AFDate_FormatEx("m/d/yy");
AFTime_Format(0);
AFSpecial_Format(3);
If they are not custom functions, it's doable. Look at the Javascript in the
annotation dictionary at /AA-/F-/JS. It's something interesting as a future
development to the library.
Paulo
Loading...