PDF Form fields are not accessibles

Hello,

I want generate PDF document with form fields (TextBoxField) in my xamarin forms application. Then, I will save and send the generated PDF document to a customer. So, the customer uses Acrobat reader to open receved PDF document and then he fills form fields. Finlay, the customer returns PDF document for that I load it in my xamarin forms application and I read form fields's values.

The problem is after the save the PDF document, the form fields are not accessibles and the saved PDF document is flatten.

Can you give me an example showing :

1) The generation of a PDF document with one form field (text box field)

2) The save of the generated PDF document.


Best regards.


1 Reply

SV Surya Venkatesan Syncfusion Team January 10, 2022 02:15 PM UTC

Hi Cosyspro,


We found reported issue occurs due to flattening the form fields in the output PDF document. If you want to edit or access the form fields in a PDF document, we recommend you do not flatten the form field. Kindly try with the following code snippet and let us know the result,

            //Create a new PDF document.

 

            PdfDocument document = new PdfDocument();

 

            //Add a new page to the PDF document.

 

            PdfPage page = document.Pages.Add();

 

            //Create a textbox field and add the properties.

 

            PdfTextBoxField textBoxField = new PdfTextBoxField(page, "FirstName");

 

            textBoxField.Bounds = new Syncfusion.Drawing.RectangleF(0, 0, 100, 20);

 

            textBoxField.ToolTip = "First Name";

 

            //Add the form field to the document.

 

            document.Form.Fields.Add(textBoxField);

 

            //Creating the stream object

 

            MemoryStream stream = new MemoryStream();

 

            //Save the document as stream

 

            document.Save(stream);

 

            //If the position is not set to '0' then the PDF will be empty.

 

            stream.Position = 0;

 

            //Close the document.

 

            document.Close(true);

 

            File.WriteAllBytes($"../../../Output.pdf", stream.ToArray());

The above code snippet generated output document: https://www.syncfusion.com/downloads/support/directtrac/general/pd/Output211366255 for your reference.


Kindly refer to the following links to get more details,

https://help.syncfusion.com/file-formats/pdf/working-with-forms#adding-the-text-box-field


If the issue persists, kindly revert us with the complete code snippet or modified sample to replicate the issue.


Regards,

Surya V


Loader.
Up arrow icon