RichText.Replace

Replace(char, char)

このインスタンスで出現する指定された Unicode 文字をすべて、指定された別の Unicode 文字に置き換えます。

public RichText Replace(char oldChar, char newChar)
パラメータタイプ説明
oldCharChar古い char.
newCharChar新しい char.

戻り値

RichText.

関連項目


Replace(string, string)

現在のインスタンス内の指定された文字列のすべてのオカレンスを別の指定された文字列に置き換えます。

public RichText Replace(string oldValue, string newValue)
パラメータタイプ説明
oldValueString古い値.
newValueString新しい値。

戻り値

RichText.

例外

例外調子
ArgumentNullException
ArgumentException

ページのテキストを通過させて置換する方法を示します。

// ドキュメント ディレクトリへのパス。
string dataDir = RunExamples.GetDataDir_Text();

Dictionary<string, string> replacements = new Dictionary<string, string>();
replacements.Add("voice over", "voice over new text");

// ドキュメントを Aspose.Note にロードします。
Document oneFile = new Document(dataDir + "Aspose.one");

IList<Page> pageNodes = oneFile.GetChildNodes<Page>();

// すべての RichText ノードを取得します
IList<RichText> textNodes = pageNodes[0].GetChildNodes<RichText>();

foreach (RichText richText in textNodes)
{
    foreach (KeyValuePair<string, string> kvp in replacements)
    {
        // 図形のテキストを置き換える
        richText.Replace(kvp.Key, kvp.Value);
    }
}

// サポートされている任意のファイル形式に保存
dataDir = dataDir + "ReplaceTextOnParticularPage_out.pdf";
oneFile.Save(dataDir, SaveFormat.Pdf);

テンプレート内の特殊なテキスト部分を置き換えて新しいドキュメントを生成する方法を示します。

string dataDir = RunExamples.GetDataDir_Text();

var D = new Dictionary<string, string>
            {
                { "Company", "Atlas Shrugged Ltd" },
                { "CandidateName", "John Galt" },
                { "JobTitle", "Chief Entrepreneur Officer" },
                { "Department", "Sales" },
                { "Salary", "123456 USD" },
                { "Vacation", "30" },
                { "StartDate", "29 Feb 2024" },
                { "YourName", "Ayn Rand" }
            };

// テンプレート ドキュメントを Aspose.Note にロードします。
var d = new Document(Path.Combine(dataDir, "JobOffer.one"));

// すべてのテンプレート単語を置き換えましょう
foreach (var e in d.GetChildNodes<RichText>())
{
    foreach (var replace in D)
    {
        e.Replace($"${{{replace.Key}}}", replace.Value);
    }
}

d.Save(Path.Combine(dataDir, "JobOffer_out.one"));

関連項目


Replace(string, string, TextStyle)

現在のインスタンスで出現する指定された文字列をすべて、指定されたスタイルの別の指定された文字列に置き換えます。

public RichText Replace(string oldValue, string newValue, TextStyle style)
パラメータタイプ説明
oldValueString古い値.
newValueString新しい値。
styleTextStyle新しい値のスタイル.

戻り値

RichText.

例外

例外調子
ArgumentNullException
ArgumentException

関連項目