Reading HTML tags from PDF

Product: WebViewer

Product Version: Latest

I would like to read fields (with data attributes) from PDF.

Description:
I have a PDF containing placeholders which should prompt the user to add texts, tick a checkbox, add a date etc. These placeholders are basically tags with data attributes.

On the WebViewer, I would like to detect those placeholders, create form fields and place them in that exact position where the placeholders are present and take input from user’s keyboard accordingly.

How can I achieve this ?

Hello idrees,

What you can do is to get placeholder’s rectangle position (coordinates) and use it to create form field annotations programmatically, as shown in this guide (there are multiple examples):

Hope this helps.

All the best,
Bojan

Yes, that is the exact thing which I would like to do. But, the data attributes is what I need to fetch for some data which I require while creating these form fields.

Example: <span id="placeholder-sign-field" data-assignee="ABC">[[placeholder]]</span>

Assume that the above span is present on the PDF. Using search, I could get the position of the span, but would need the values of data attributes “assignee” (in this example).

Any solution for this ?

Hello idrees,

  1. Can you clarify what you mean by “span is on the PDF”?
  2. Can you provide a sample for us to reproduce?
  3. Can you provide a sample document to reproduce?

Typically you would get a data element by doing a querySelector on the DOM.