locked
Help, to set all formfield readonly in pdf RRS feed

  • Question

  • I want to protect my PFD,and just show it as a template. Some formfiels on it, include checkbox,textboxfield and combo box, how to set them readonly. Is there any way to do it? 

    Any help will be appriciated....

    • Moved by Caillen Thursday, April 9, 2015 8:58 AM
    Friday, April 3, 2015 4:43 AM

Answers

  • Please post questions related to using third-party products in their forums.  These forums are for MS products and frameworks.
    • Proposed as answer by Caillen Thursday, April 9, 2015 8:57 AM
    • Marked as answer by Just Karl Wednesday, April 15, 2015 8:27 PM
    Friday, April 3, 2015 2:45 PM

All replies

  • Not a hard thing.Here is an article exactly helps you ......

    How to set read-only fields on a form.

    Just download this free PDF API ,add the reference to your project and add the following code .

    PdfDocument doc = new PdfDocument();
    doc.LoadFromFile("FormField.pdf");
    
    PdfFormWidget widget = doc.Form as PdfFormWidget;
    
    for (int i = 0; i < widget.FieldsWidget.List.Count; i++)
       {
         PdfField f = widget.FieldsWidget.List[i] as PdfField;
         if (f.Name == "username")
            {
               PdfTextBoxFieldWidget textboxField = f as PdfTextBoxFieldWidget;
               textboxField.Text = "Sky.Luo";
            }
               f.Flatten = true;
               f.ReadOnly = true;
       }
    doc.SaveToFile("FormFieldEdit.pdf");
    System.Diagnostics.Process.Start("FormFieldEdit.pdf");


    Friday, April 3, 2015 4:48 AM
  • Please post questions related to using third-party products in their forums.  These forums are for MS products and frameworks.
    • Proposed as answer by Caillen Thursday, April 9, 2015 8:57 AM
    • Marked as answer by Just Karl Wednesday, April 15, 2015 8:27 PM
    Friday, April 3, 2015 2:45 PM