こんにちは世界!
「ハロー、ワールド!」このコードは、多くの場合、「Aspose.Words for .NET」を使用して作成する最初の簡単な例であり、ソース コードをコンパイルまたは実行するためのソフトウェアが正しくインストールされていることを確認する健全性テストとしても使用できます。
「Aspose.Words for .NET」C# ライブラリを使用すると、開発者は Word および Web ドキュメントを作成、変更、マージ、変換、比較するために直接アクセスできます。 PDF、DOCX、DOC、RTF、ODT、EPUB、HTML、その他多くのファイル形式は サポートされているドキュメント形式 です。
Below code スニペットは次の手順に従います。
- 新しい空の Document を作成します。
- DocumentBuilder クラスを初期化する
- 単純な Write メソッドを使用してドキュメントにテキストを挿入します。
- ファイルから既存の Document を開きます。ファイル形式を自動的に検出します
- Append ドキュメント「A」からドキュメント「B」まで
- PDF として出力を Save する
次のコード スニペットは「Hello, World!」です。 「Aspose.Words for .NET」API の動作を示す例:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET.git. | |
Document docA = new Document(); | |
DocumentBuilder builder = new DocumentBuilder(docA); | |
// Insert text to the document start. | |
builder.MoveToDocumentStart(); | |
builder.Write("First Hello World paragraph"); | |
Document docB = new Document(MyDir + "Document.docx"); | |
// Add document B to the and of document A, preserving document B formatting. | |
docA.AppendDocument(docB, ImportFormatMode.KeepSourceFormatting); | |
docA.Save(ArtifactsDir + "HelloWorld.SimpleHelloWorld.pdf"); |