HTML
JPG
PDF
XML
DOCX
PDF
クラウド .NET SDK を使用して PDF ドキュメントで注釈を操作する方法
クラウド .NET SDK を介して PDF ドキュメントで注釈を操作するために、使用します Aspose.PDF Cloud .NET SDK このクラウド SDK を使用すると、C#、ASP.NET、またはその他の .NET 言語でさまざまなクラウドプラットフォーム向けのクラウドベースの PDF 作成、編集、変換アプリを簡単に構築できます。開く NuGet パッケージマネージャーを検索し、 Aspose.PDF Cloud をインストールします。パッケージ マネージャー コンソールから以下のコマンドを使用することもできます。
パッケージ マネージャー コンソール コマンド
PM> Install-Package Aspose.Pdf-Cloud
.NET SDK を使用して注釈を追加する手順
Aspose.PDF Cloud 開発者は、ほんの数行のコードで PDF ドキュメントに簡単に注釈を読み込み、追加できます。
- PDF をアップロードします。
- スタイル付きテキストボックスを作成します(フォント、色、配置)。
- 指定されたページに注釈を送信します。
- 変更された文書をダウンロードしてローカルで使用します。
このサンプルコードはPDF文書に注釈を追加することを示しています
using Aspose.Pdf.Cloud.Sdk.Model;
namespace Annotations
{
public class NewFreetextAnnotation
{
public static async Task Append(AnnotationsHelper helper, string documentName, int pageNumber, string outputName, string remoteFolder)
{
await helper.UploadFile(documentName);
List<FreeTextAnnotation> annotations = new List<FreeTextAnnotation>
{
new FreeTextAnnotation(
Name: "Freetext_NEW_Annotation",
Rect: new Rectangle(100,350, 450,400),
Flags: new List<AnnotationFlags>() { AnnotationFlags.Default },
HorizontalAlignment: HorizontalAlignment.Left,
Intent: FreeTextIntent.FreeTextTypeWriter,
Justification: Justification.Center,
RichText: helper.config.NEW_FT_ANNOTATION_TEXT,
Subject: helper.config.NEW_FT_ANNOTATION_SUBJECT,
Contents: helper.config.NEW_FT_ANNOTATION_CONTENTS,
Title: helper.config.NEW_FT_ANNOTATION_DESCRIPTION,
ZIndex: 1,
TextStyle: new TextStyle(
FontSize: 20,
Font: "Arial",
ForegroundColor: new Color( A: 0xFF, R: 0x00, G: 0xFF, B: 0x00),
BackgroundColor: new Color( A: 0xFF, R: 0xFF, G: 0x00, B: 0x00)
),
Modified: "03/27/2025 00:00:00.000 AM"
)
};
AsposeResponse response = await helper.pdfApi.PostPageFreeTextAnnotationsAsync(documentName, pageNumber, annotations, folder: remoteFolder);
if (response == null)
Console.WriteLine("NewFreetextAnnotation(): Unexpected error!");
else if (response.Code < 200 || response.Code > 299)
Console.WriteLine("NewFreetextAnnotation(): Failed to append text annotation to the document.");
else
{
Console.WriteLine("NewFreetextAnnotation(): annotations '{0}' added to the document '{1}.", helper.config.NEW_FT_ANNOTATION_TEXT, documentName);
await helper.DownloadFile(documentName, outputName, "add_text_annotation_");
}
}
}
}