|
|
|
|
|
This appears to work. Tweak the control.FieldType condition to include/exclude fields. Code:
foreach (PdfField control in _forms.InterForm.Fields)
{
if (control.FieldType == FormFieldTypes.FPDF_FORMFIELD_TEXTFIELD
|| control.FieldType == FormFieldTypes.FPDF_FORMFIELD_CHECKBOX
|| control.FieldType == FormFieldTypes.FPDF_FORMFIELD_COMBOBOX)
{
string k;
PdfTypeBase v;
bool hasFlags = false;
foreach (var d in control.Dictionary)
{
k = d.Key;
v = d.Value;
if (d.Key == "Ff" && v.ObjectType == IndirectObjectTypes.Number)
{
hasFlags = true;
PdfTypeNumber n = (PdfTypeNumber)v;
n.IntValue = n.IntValue | (int)FieldFlags.ReadOnly;
}
}
if (!hasFlags)
{
PdfTypeNumber fieldFlags = PdfTypeNumber.Create((int)FieldFlags.ReadOnly);
control.Dictionary.Add(new KeyValuePair<string, PdfTypeBase>("Ff", fieldFlags));
}
}
}
|
|
|
Hi - I dug into the Dictionary for each field and found that key "Ff" relates to FieldFlags. I can set the read only flag via IntValue() however, I am getting inconsistent results because not all fields have an "Ff" in their dictionary. Is there another way to set the FieldFlags, or should I add "Ff" to the dictionary (if that is even possible)? Code:
foreach (PdfField control in _forms.InterForm.Fields)
{
//if (control.FieldType == FormFieldTypes.FPDF_FORMFIELD_TEXTFIELD)
//{
string k;
PdfTypeBase v;
foreach (var d in control.Dictionary)
{
k = d.Key;
v = d.Value;
[h]if (d.Key == "Ff" && v.ObjectType == IndirectObjectTypes.Number)[/h]
{
PdfTypeNumber n = (PdfTypeNumber)v;
n.IntValue = n.IntValue | (int)FieldFlags.ReadOnly; // ReadOnly == 1
}
}
//}
}
|
|
|
Hi
I am setting the value for interactive form fields, then using Save to create a PDF. The PDF is sent to the user who will view with Acrobat reader etc. I need a way to prevent the user from changing a field value.
Is it possible to set the PdfField Flags property? Or, is it possible to set a Document readonly property? Or, is it possible to flatten a field so that it becomes static text on the PDF?
Thanks! D
|
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close