テキストの操作| C ++ APIソリューション
Contents
[
Hide
Show
]テキストを追加します
XPSドキュメントにテキストを追加します
C ++のAspose.Pageでは、C ++アプリケーションのXPSドキュメントにテキストを追加できます。 xpsglyphsクラスでは、選択したブラシを指定してXPSドキュメントにテキストを追加できます。 テキストは、次の手順を使用してXPSドキュメントに追加できます。
- XPSDocumentクラスの新しいインスタンスを作成します
- xpssolidcolorbrushクラスを使用してブラシを作成します
- グリフを追加必要なフォント情報を備えたドキュメントオブジェクトに
- XPSDocumentクラスの Saveメソッドを使用してファイルを保存します
次のコードスニペットは、C ++を使用してXPSドキュメントにテキストを追加するための完全な機能を示しています。
1For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-C
2// Create new XPS Document
3auto doc = System::MakeObject<XpsDocument>();
4//Create a brush
5System::SharedPtr<XpsSolidColorBrush> textFill = doc->CreateSolidColorBrush(System::Drawing::Color::get_Black());
6//Add glyph to the document
7System::SharedPtr<XpsGlyphs> glyphs = doc->AddGlyphs(u"Arial", 12.0f, System::Drawing::FontStyle::Regular, 300.f, 450.f, u"Hello World!");
8glyphs->set_Fill(textFill);
9// Save resultant XPS document
10doc->Save(outDir() + u"AddText_out.xps");
エンコード文字列を使用してテキストを追加します
C ++のAspose.Pageは xpsglyphsクラスを提供します。 ヘブライ語またはアラビア語のテキストのように、左から右から右から右から右から右への変更を変更する必要がある場合、bidilevelプロパティを変更します。デフォルト値は「0」です。
1glyphs->set_BidiLevel(1);
次のコードスニペットは、エンコード文字列を使用してテキストを追加する完全な機能を示しています。
1For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-C
2// Create new XPS Document
3auto doc = System::MakeObject<XpsDocument>();
4// Add Text
5System::SharedPtr<XpsSolidColorBrush> textFill = doc->CreateSolidColorBrush(System::Drawing::Color::get_Black());
6System::SharedPtr<XpsGlyphs> glyphs = doc->AddGlyphs(u"Arial", 20.0f, System::Drawing::FontStyle::Regular, 400.f, 200.f, u"++C. rof SPX.esopsA");
7glyphs->set_BidiLevel(1);
8glyphs->set_Fill(textFill);
9// Save resultant XPS document
10doc->Save(outDir() + u"AddText_out.xps");