Is there any option to make whole PDF form non editable and display the annotations using WebViewer?

193 views
Skip to first unread message

Vinoth Kumar

unread,
Jun 8, 2016, 4:56:47 PM6/8/16
to PDFTron WebViewer
Hi,

Is there any option to make whole PDF form non editable and display the annotations using WebViewer?

We tried 'enableReadOnlyMode' option but it only makes the existing annotations/fields readonly. But we need to make the whole PDF form as readonly with existing annotations.

Regards,
Vinoth

Matt Parizeau

unread,
Jun 9, 2016, 4:43:48 PM6/9/16
to PDFTron WebViewer
Hi Vinoth,

You could add code like the following to your config file:

$(document).on('viewerLoaded', function() {
 
var docViewer = readerControl.docViewer;
  docViewer
.on('pageComplete', function() {
    $
('[id^=pageWidgetContainer] div').each(function() {
     
var $this = $(this);
      $this
.find('input,textarea').prop('readonly', true);
      $this
.find('input[type=checkbox]').prop('disabled', true);
   
});
 
});
});

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Vinoth Kumar

unread,
Jun 13, 2016, 12:36:40 PM6/13/16
to PDFTron WebViewer
Hi Matt,

This is working for us. Thank you so much.

Regards,
Vinoth

Vinoth Kumar

unread,
Aug 8, 2016, 12:48:54 PM8/8/16
to PDFTron WebViewer
Hi Matt,

When the pageComplete event called in 'Nexus 7' tablet (Android 6.0.1), the $('[id^=pageWidgetContainer] div') is empty, so the disabling didn't work.

The same is working on 'Galaxy S4' (Android 5.0.1).

Please advice. 

Thanks in advance.

Regards,
Vinoth

Matt Parizeau

unread,
Aug 9, 2016, 7:01:32 PM8/9/16
to PDFTron WebViewer
Hi Vinoth,

I'm having trouble reproducing the issue. Would you be able to send the document you're using to test and let me know which WebViewer version you're using?

Thanks,

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Yedhu Krishnan

unread,
Aug 10, 2016, 12:53:39 PM8/10/16
to PDFTron WebViewer
Hi Matt,

I'm replying on behalf of Vinoth. I've sent the document we used to test to sup...@pdftron.com with subject line: "Sample PDF Document - for Read Only issue".

We are using WebViewer version 2.2.0.

Please let me know if you could reproduce the issue with this document.

Thanks,

Yedhu Krishnan

Matt Parizeau

unread,
Aug 11, 2016, 5:08:58 PM8/11/16
to PDFTron WebViewer
Hi Yedhu,

Thanks for sending the document! I'm still having trouble reproducing the issue however. I tested on a Nexus 9 (Android 6.0) in Chrome and it seems to be disabling the fields for me. Are you using a different browser?

Would you be able to send a full sample project or a link to your site where you're able to reproduce the issue?

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Yedhu Krishnan

unread,
Aug 16, 2016, 12:40:19 PM8/16/16
to PDFTron WebViewer
Hi Matt,

I have created a branch with our sample document here: https://github.com/yedhukrishnan/webviewer-demo/tree/editable_form

The problem is in this specific line of config file (which is loaded while initialising WebViewer): https://github.com/yedhukrishnan/webviewer-demo/blob/editable_form/www/templateConfig.js#L35

When the ‘pageComplete’ event is fired, the element ‘$('[id^=pageWidgetContainer] div')’ is not present. Because of that, it’s not setting the ‘readonly’ property.

Let me know your thoughts.

Thanks,

Yedhu Krishnan

Matt Parizeau

unread,
Aug 17, 2016, 4:15:40 PM8/17/16
to PDFTron WebViewer
Hi Yedhu,

Thanks very much for providing a sample project! Unfortunately I'm still unable to reproduce the issue as you're describing it. What I have seen is if I tap very quickly after the page renders then sometimes I can select a field but anytime after that it seems like the fields are being set to readonly. Is this the problem you're seeing or are the fields always editable even if you wait for a second before selecting them? Note that as mentioned in a previous post I'm testing on a Nexus 9 with Android 6.0.

If you place the code to set values to readonly in a setTimeout does that seem to make a difference?

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Vinoth Kumar

unread,
Aug 18, 2016, 2:10:44 PM8/18/16
to PDFTron WebViewer
Hi Matt,

Thanks a lot for the suggestion. After adding the delay, it worked. 

Regards,
Vinoth
Reply all
Reply to author
Forward
0 new messages