HTML
JPG
PDF
XML
DOCX
PDF
Cloud .NET SDKを使用してPDFドキュメントからページ注釈を取得する方法
PDFドキュメントからページ注釈を取得するには、 Aspose.PDF Cloud .NET SDK このCloud SDKを使用すると、C#、ASP.NET、その他の.NET言語でクラウドベースのPDFクリエイター、エディター、およびコンバーターアプリを簡単に構築できます。 NuGet パッケージマネージャーを開き、 Aspose.PDF Cloud を検索してインストールします。また、パッケージマネージャーコンソールから次のコマンドを使用することもできます。
パッケージマネージャーコンソールコマンド
PM> Install-Package Aspose.Pdf-Cloud
.NET SDKを使用して注釈を取得する手順
Aspose.PDF Cloud開発者は、数行のコードで簡単にPDFドキュメントから注釈を読み込み、取得できます。
- ドキュメントをアップロードします。
- 指定されたページからすべての注釈を取得します。
- 各注釈の詳細を記録します。
- 最初のテキスト注釈のIDを返します(編集や削除などのさらなるアクションのため)。
このサンプルコードは、C#を介してPDFドキュメントからページ注釈を取得する方法を示しています
using Aspose.Pdf.Cloud.Sdk.Model;
namespace Annotations
{
public class GetAnnotations
{
public static async Task<string> RequestAnnotationsOnPageAsync(AnnotationsHelper helper, string documentName, int pageNumber, string remoteFolder)
{
// Get annotations from the page in the PDF document.
await helper.UploadFile(documentName);
string annotationResult = string.Empty;
AnnotationsInfoResponse response = await helper.pdfApi.GetPageAnnotationsAsync(documentName, pageNumber, folder: remoteFolder);
if (response == null)
Console.WriteLine("RequestAnnotationsOnPageAsync(): Unexpected error!");
else if (response.Code < 200 || response.Code > 299)
Console.WriteLine("RequestAnnotationsOnPageAsync(): Failed to request annotations from the document.");
else
{
foreach (AnnotationInfo annotation in response.Annotations.List)
{
Console.WriteLine("RequestAnnotationsOnPageAsync(): annotation '{0}' with '{1}' contents get from the '{2}' page of the document '{3}.", [annotation.Id, annotation.Contents, pageNumber, documentName]);
if (string.IsNullOrEmpty(annotationResult) &&
annotation.AnnotationType == AnnotationType.Text)
{
annotationResult = annotation.Id;
}
}
}
return annotationResult;
}
}
}