make pdfviewer read only

I recall there was a way in Xamarin of making the pdfviewr readonly by disabling the toolbar 

there is no such functionality in the Maui version 

if one sets 'enable' to false - yes it makes it read only but one cannot scroll around th e document 

any ideas gratefully received


5 Replies

DR Deepika Ravi Syncfusion Team May 31, 2024 12:13 PM UTC

Hi john murray,


We have prepared a sample to demonstrate how to change the PDFViewer form fields and annotations interaction to read-only in SfPdfViewer. You can download the sample from the attachment.


Please find the workflow of the application,


After loading the document in the SfPdfViewer, the DocumentLoaded event will be triggered. Within this event, we have implemented the LockAllAnnotationsAndFields() method to change all annotations and form fields to read-only.


To make the form fields read-only, we set the ReadOnly property to restrict editing. Similarly, to restrict the editing of annotations in SfPdfViewer, we use the IsLocked property. The following code snippet also explains the same,


    // Locks all the annotations and form fields in the document.

    void LockAllAnnotationsAndFields()

    {

        PdfViewer.AnnotationSettings.IsLocked = true;

        if (PdfViewer.FormFields?.Count > 0)

        {

            foreach (var field in PdfViewer.FormFields)

            {

                field.ReadOnly = true;

            }

        }

    }


Please try this sample and let us know if it meets your requirement. If not, kindly share more details about your requirement. This will be helpful for us to check further.


Regards,

Deepika R


Attachment: Read_Only_9e157432.zip


AM Andreas Mey October 14, 2025 06:12 AM UTC

Hi guys!

Although this is a solution, I think it would be better to provide a separate ReadOnly property to handle signed or 'finished' interactive forms. This would ease this kind of problem and provide a straightforward way to disable or enable interaction with the form. It would further conform with the way other controls behave. What do you think? 

Have a lovely day!

Andreas



BS Bharathi Selvam Syncfusion Team October 14, 2025 06:45 PM UTC

Hi Andreas,

Thank you for reaching out. Regarding your query for a separate ReadOnly property to handle finished form field editing in SfPdfViewer. To help us better understand and check your request, could you please share more details about your use case and specific requirements?

Regards,

Bharathi S



AM Andreas Mey December 9, 2025 04:44 PM UTC

Hello Bharathi,

Sorry for the late reply. I completely overlooked your response/query. Generally speaking, once a user has filled out and, if necessary, signed the PDF form, it should only be possible to view it, not edit it. This is especially important if it has been signed, otherwise the signature would be meaningless. Example: the PDF form represents an invoice that is signed by a customer. After that, for legal reasons, no further changes should be possible, but the invoice form should still be viewable at any time. The same applies when a customer signs a contract. In this case, too, the contract form must be protected against subsequent changes. "ReadOnly" is intended to enable the document to be protected in a simple manner by setting a single property. The workaround of setting all fields to read-only achieves the goal, but is unnecessarily complex. For this reason, other Syncfusion controls such as SfRichTextEditor also offer this property.

It would be great if you could implement the ReadOnly property for SfPdfViewer.

Thank you in advance.


Season's greetings,

Andreas



BS Bharathi Selvam Syncfusion Team December 10, 2025 06:07 PM UTC

Hi Andreas,

In Xamarin.Forms, the behavior for restricting editing of AcroForm fields is documented here:
Working with PDF forms in Xamarin Pdf Viewer control | Syncfusion

Could you please confirm if your expectation for .NET MAUI is to have the same behavior as described in the above Xamarin link?

Currently, .NET MAUI SfPdfViewer does not have a built-in ReadOnly property, but you can achieve similar functionality using the following workaround only:

If your requirement is specifically to prevent changes to signature fields after signing, you can lock only the signature fields after the document is signed:

 void LockSignatureFields()

{

    if (PdfViewer.FormFields?.Count > 0)

    {

        foreach (var field in PdfViewer.FormFields)

        {

            // Correct approach: check for SignatureFormField type

            if (field is SignatureFormField signatureField)

            {

                signatureField.ReadOnly = true; // Prevent further edits

            }

        }

    } 

    // Optionally lock annotations if signatures are represented as annotations

    PdfViewer.AnnotationSettings.IsLocked = true;

}


Please let us know if this approach meets your requirement or if you need a sample demonstrating this in .NET MAUI.

Regards,

Bharathi S


Loader.
Up arrow icon