This is a sample of Java code that adds Javascript to a fillable PDF to
change some fields to read only. Making them hidden would work the same way.
// Vector readOnlyFields contains the names of fields I want to be
read only
boolean first = true;
StringBuffer sb = new StringBuffer();
for (Enumeration e = readOnlyFields.elements();
e.hasMoreElements(); ){
field = (String) e.nextElement();
field = field.toLowerCase();
if (first){
first = false;
sb.append("var array1 = [");
}else{
sb.append(",");
}
sb.append("'" + field + "'");
}
if (sb.length() > 0){
sb.append("];\n");
sb.append("for (i = 0; i < array1.length; i++){\n");
sb.append(" try{\n");
sb.append(" f = this.getField(array1[i]);\n");
sb.append(" if (f != null){\n");
sb.append(" f.readonly = true;\n");
sb.append(" }\n");
sb.append(" }catch(e){\n");
sb.append(" console.println(array1[i] + ' ' + e);\n");
sb.append(" }\n");
sb.append("}\n");
writer.addJavaScript(sb.toString());
}
----- Original Message -----
From: "javier muguruza" <[EMAIL PROTECTED]>
To: "Steve Cole" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, December 09, 2004 9:38 AM
Subject: Re: [iText-questions] how to set a form field to invisible
Thanks for the answer Steve,
is there any example of using js this way?
On Thu, 9 Dec 2004 09:35:05 -0500, Steve Cole <[EMAIL PROTECTED]> wrote:
> If iText can't directly change the field property, you can always use
iText
> to add a Javascipt to the PDF that will change the field property hidden
to
> true.
>
>
>
> ----- Original Message -----
> From: "javier muguruza" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, December 09, 2004 9:14 AM
> Subject: [iText-questions] how to set a form field to invisible
>
> Hi,
>
> I have started to use itext, some things are tried are easy with the
> examples, others, I cannot see how I could achieve them, I cannot find
> any doc about them.
>
> I have a form inside a pdf, and I want to set a field from that form
> to be visible programatically. How can I do that? Once I find out this
> I guess it will be easy to set it to rean only etc. But I dont see how
> I could change the settings of a form field...is there any example
> available somewhere?
>
> TIA
> javier
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://productguide.itmanagersjournal.com/
> _______________________________________________
> iText-questions mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
>
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions