Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Remove some of the Text Formatting from the Rich text coming from an DataXML

Avatar

Level 2

Dear Experts,

I am currently working on the PDF creation for Quotation. Now we have an option to add a "Note" where a Sales Employee can add some text.

And we make that text visible on PDF which is working perfectly fine.

However we want to get rid of the formatting the Sales user has done on the Text Level , Below is the Exact content text.

<ContentText>

<div<div><p>

<span style="font-family: arial ; font-size: 10pt">

<strong>In der Dichtungstechnik ist es gängige Praxis, als Unterstützung einer technischen Absicherung Werkstoffdatenblätter anzufordern.</strong>

</span><br><br>

<span style="font-size: 18pt">In aller Regel handelt es sich hierbei um Werkstoffdaten, die an genormten Prüfplatten ermittelt wurden.

Diese Werkstoffdatenblätter geben anhand der ermittelten Ist-Werte Aufschluss über die Qualität bzw.

das Potential einer Werkstoffrezeptur.</span>

<span style="font-size: 18pt ; color: #e20808">

</span><br><br>

<span style="color: #e20808">Um zusätzliche Aussagen über die Verarbeitungsqualität von Fertigteilen treffen zu können, haben wir bei

TSS darüber hinaus für unsere wichtigsten Compounds sogenannte O-Ring-Datenblätter erstellt, die Ihnen helfen sollen, die Qualität der

Fertigprodukte übergreifend (Qualität der Werkstoffrezeptur und Qualität der Verarbeitung des Werkstoffes) beurteilen zu können.

</span></p></div></div></ContentText>

Now as you can see I want to get rid of font-family , font size and colour.

Can some 1 please help me in this? Thanks a lot for this community. So far it have been great

BR

Dhruvin

1 Accepted Solution

Avatar

Correct answer by
Level 2

Hi BR001

I was able to do it with use of Regex in JS.

so field has Rich text below code I use.

FormQuoteNotification.bdyMain.frmAddInfoBlock.frmInfoBlockCustomerInformation.txtContentValue::initialize - (JavaScript, client)

var tmp = txtContentValue.value.exData.saveXML("pretty");

tmp = tmp.replace(/ style="[^"]*"/g,"");

txtContentValue.value.exData.loadXML(tmp,1,1);

And i used website regexr to find my regular expression.

I hope it will help for users who has similar issue like me.

BR

Dhruvin

View solution in original post

5 Replies

Avatar

Level 2

Dear All,

Is above issue not possible to solve?

BR

Dhruvin

Avatar

Level 10

Is this markup being passed into the form?  It doesn't look like the sort of markup you get from a rich text field within a form.

Maybe look at using E4X, a JavaScript extension to handle XML, to remove the bits you don't want. There is a sample here  Adobe LiveCycle Designer Cookbooks by BR001: Adding values in a form to an email

E4X has been removed from most JavaScript engines but is still part of Reader, so I guess at some point in the future it will be removed as well.

Avatar

Level 2

Hi BR001

Thanks for your feedback , Is this markup being passed into the form?  Yes.

We are working on a SAP project where SAP system passes theis info in a field and show the same in a Rich text field on form.

Which works perfect however I want to remove some tags.

To be honest i have no clue what is E4X can u please shade some light in it and how can i use it?

BR

Dhruvin

Avatar

Level 10

E4X is a obsolete thing, so there's not a lot of info left about it.  It has been retained in Adobe Reader so I suspect it might be for awhile, but I'm not to know.

I gave you a link to sample and there's still some info on MDN, Processing XML with E4X - Archive of obsolete content | MDN

I think you should look at this sort of processing being done on the server, as opposed to to the presentation layer.

But failing that, E4X is probably better than a lot of string manipulations or regex processing.

Avatar

Correct answer by
Level 2

Hi BR001

I was able to do it with use of Regex in JS.

so field has Rich text below code I use.

FormQuoteNotification.bdyMain.frmAddInfoBlock.frmInfoBlockCustomerInformation.txtContentValue::initialize - (JavaScript, client)

var tmp = txtContentValue.value.exData.saveXML("pretty");

tmp = tmp.replace(/ style="[^"]*"/g,"");

txtContentValue.value.exData.loadXML(tmp,1,1);

And i used website regexr to find my regular expression.

I hope it will help for users who has similar issue like me.

BR

Dhruvin