Edit Font Format in HTML Document Preview

ErinF
Tera Expert

Is there a way to add a formatter in the preview editor of an HTML document template? 

When an agent is editing a document, they can use keyboard shortcuts to bold/underline in the preview editor, but we need a way to allow them to add/remove highlighting before generating the pdf of the document. 

 

Thanks!

1 REPLY 1

JamesEcoStratus
Mega Guru

Hi, based on my understanding of your question from the information you’ve provided, see my answer below.

 

To the best of my knowledge, ServiceNow's HTML editor for document templates may not have native support for adding custom formatters directly within the preview editor. However, you can achieve the desired functionality by adding custom HTML and CSS to your document template.

 

Here's a general approach to adding custom highlighting options:

 

Customize the Document Template:

Go to the document template you want to customize.

Edit the template in the HTML editor.

 

Add Custom CSS:

You can include custom CSS styles within your HTML template. Define CSS classes for different types of highlighting, such as background colors for highlighting text.

 

For example:

 

Screenshot 2023-09-05 at 15.02.22.png

 

Add HTML Elements for Highlighting:

Within your document template's HTML, you can add HTML elements that represent different highlighting options. These could be buttons, links, or any other user interface elements you prefer.

 

For example:

 

Screenshot 2023-09-05 at 15.01.42.png

 

JavaScript for Applying Highlights:

You can use JavaScript to apply the selected highlighting style to the text within the HTML document. You can attach event handlers to the highlighting elements to toggle the highlighting styles on/off.

 

Here's a simplified example:

 

Screenshot 2023-09-05 at 15.13.54.png

 

The JavaScript code above surrounds the selected text with a <span> element having the chosen highlight class when a user clicks the corresponding button.

 

Testing and Validation:

 

After making these customizations, test the document template to ensure that the highlighting functions as expected in the HTML preview editor.

 

Be sure to check the latest ServiceNow documentation or consult with your organization's ServiceNow administrator or developer to explore any new native features or enhancements that may have been added to support advanced document template editing.

 

Good Luck!

 

James @Ecostratus

 

If I helped you with your question, then please hit the Thumb Icon and mark it as Helpful or Correct.