Skip to main content
Participating Frequently
April 2, 2019
Question

convert html string to formatted string in adobe acrobat DC

  • April 2, 2019
  • 2 replies
  • 2177 views

Hey,

How to convert html string to formatted string in Adobe acrobat forms.

E.g. Input/ form field value is

<html>

     <body>

          <p>Hi</p>

          <b>Text1</b></br>

          <s>Text2</s>

          <p>end</p>

     </body>

</htm>

I want the output/display the form field value should be

Hi

Text1

Text2​ end

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
April 2, 2019

You will need to write your own HTML parser that generates Span objects.

It's not a simple task, at all.

On Tue, Apr 2, 2019, 20:44 bharanig38097311 <forums_noreply@adobe.com>

Thom Parker
Community Expert
Community Expert
April 2, 2019

Possible but very complicated. What you are looking for is Rich Text.  So, a PDF text field will accept an array of "Spans", where each span is a Rich Text object.  Spans are a very poor country cousin to HTML, so the options are limited.

Here's the reference entry.

Acrobat DC SDK Documentation

There are many more undocumented options.  Use Acrobat to enter formatted text in to a text field, then display the "spans" used to build it.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participating Frequently
April 2, 2019

Thanks for your quick reply.

As i mentioned above my input is a formatted html string.

<p>Hi</p>

          <b>Text1</b></br>

          <s>Text2</s>

          <p>end</p>

In adobe java script i have to read each line and then convert into spans?. Let me know if my understanding is not correct.

If so is it possible to create spans for number formatted list and lists with bullet points?

Thom Parker
Community Expert
Community Expert
April 2, 2019

You are correct that the parser script has to read the HTML text and then convert it into spans.  However, like I said, the conversion options are limited. Read the reference entry!! 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often