Conversion RTF to ANSI - hidden text is shown

  • We use the following routine to convert RTF to ANSI:

    Code
    function TWPTTextTransformer.RTF2Str(v: string): string;begin    wpt.TextLoadFormat := 'RTF';    wpt.AsString := v;    wpt.TextSaveFormat := 'ANSI';    result := wpt.AsString;end;

    (wpt is a TWPRichTextEdit)

    Now we have the issue that some customer came up with some text to convert that contains hidden parts, (using \v1). Whereas this hidden text is not shown on the TWPRichText it is part of the converted text.

    Is there a way to ignore hidden text during conversion?

    Here's the problematic RTF text:

    Code
    {\rtf1\ansi\deff0\uc1\ansicpg1252\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}{\f1\fnil\fcharset1 Times New Roman;}{\f2\fnil\fcharset2 Wingdings;}}{\colortbl\red0\green0\blue0;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;\red255\green255\blue0;\red255\green0\blue255;\red128\green0\blue128;\red128\green0\blue0;\red0\green255\blue0;\red0\green255\blue255;\red0\green128\blue128;\red0\green0\blue128;\red255\green255\blue255;\red192\green192\blue192;\red128\green128\blue128;\red0\green0\blue0;\red128\green128\blue0;}\wpprheadfoot1\paperw12240\paperh15840\margl1800\margr1800\margt1440\margb1440\headery254\footery254\pgbrdrhead\pgbrdrfoot\pgbrdropt32\endnhere\sectdefaultcl{\*\generator WPTools_6.030;}{\stylesheet
    {\s1\li0\fi0\ri0\sb0\sa0\ql\vertalt\fs24 Normal;}
    {\s2\li0\fi0\ri0\sb0\sa0\ql\vertalt\fs22 Default Paragraph Font;}
    {\s3\li0\fi0\ri0\sb0\sa0\ql\vertalt\fs22\cf3\ul\sbasedon2 Hyperlink;}
    {\s4\li0\fi0\ri0\sb0\sa0\ql\vertalt\fs22\cf6\ul FollowedHyperlink;}}
    {\pard\plain\plain\fs22\cf0\par'#$D#$A'\plain\fs22\cf0 Tel.: 01234-56789  Fax: 01234-56789  \line blablabla \line E-Mail: \ul IamNotHidden\f1\fs24\v1\ulnone IamHidden\f0\fs22\v0\ulnone   oder blabla
    \pard\plain\wpparid0\plain\cs3\fs22\ul\par
    }}