escapeSpecialChar() function to display special characters on the item label PDF print.

To generate and print labels for items that had an “&” symbol in the “Purchase Description” field, we can use escapeSpecialChar() function.

function escapeSpecialChar(textvalue) {

            try {
                textvalue = textvalue.replace(/&/g, '&');
                textvalue = textvalue.replace(/</g, '&lt;');
                textvalue = textvalue.replace(/>/g, '&gt;');
                textvalue = textvalue.replace(/"/g, '');
                textvalue = textvalue.replace(/'/g, '');
                textvalue = textvalue.replaceAll("$", "");
                return textvalue;
            } catch (e) {
                log.error({
                    title: e.name,
                    details: e
                });
            }

        }

Leave a comment

Your email address will not be published. Required fields are marked *