HTML
JPG
PDF
XML
DOCX
PDF
Ganti Anotasi Teks dalam PDF via .NET SDK
API untuk mengganti anotasi dalam dokumen PDF dengan Aspose.PDF Cloud .NET SDK.
Get StartedCara Mengganti Anotasi Teks dalam dokumen PDF menggunakan Cloud .NET SDK
Untuk mengganti anotasi teks dalam dokumen PDF, kita akan menggunakan Aspose.PDF Cloud .NET SDK Cloud SDK ini memungkinkan Anda dengan mudah membangun aplikasi pembuat, penyunting & konverter PDF berbasis cloud dalam C#, ASP.NET, atau bahasa .NET lainnya untuk berbagai platform cloud. Buka NuGet pengelola paket, cari Aspose.PDF Cloud dan instal. Anda juga dapat menggunakan perintah berikut dari Konsol Pengelola Paket.
Perintah Konsol Pengelola Paket
PM> Install-Package Aspose.Pdf-Cloud
Langkah-langkah untuk mengganti anotasi menggunakan .NET SDK
Pengembang Aspose.PDF Cloud dapat dengan mudah memuat & mengganti anotasi dalam dokumen PDF hanya dalam beberapa baris kode.
- Unggah dokumen ke cloud.
- Dapatkan Anotasi menggunakan GetTextAnnotationAsync().
- Modifikasi Isi dan Ikon Anotasi.
- Simpan Perubahan Kembali ke Cloud
- Unduh dokumen yang telah diperbarui.
Kode contoh ini menunjukkan cara mengganti Anotasi Teks dalam dokumen PDF melalui C#
using Aspose.Pdf.Cloud.Sdk.Model;
using System.Runtime.Intrinsics.X86;
namespace Annotations
{
public class ReplaceAnnotation
{
public static async Task<TextAnnotation> GetAnnotationAsync(AnnotationsHelper helper, string documentName, string annotationId, string remoteFolder)
{
// Get annotation by Id in the PDF document.
TextAnnotation annotationResult = null;
TextAnnotationResponse response = await helper.pdfApi.GetTextAnnotationAsync(documentName, annotationId, folder: remoteFolder);
if (response == null)
Console.WriteLine("GetAnnotationAsync(): Unexpected error!");
else if (response.Code < 200 || response.Code > 299)
Console.WriteLine("GetAnnotationAsync(): Failed to request text annotation from the document.");
else
{
Console.WriteLine("GetAnnotationAsync(): annotation '{0}' with '{1}' contents successfully found in the document '{2}.", response.Annotation.Id, response.Annotation.Contents, documentName);
annotationResult = response.Annotation;
}
return annotationResult;
}
public static async Task ModifyAsync(AnnotationsHelper helper, string documentName, string outputName, string annotationId, string remoteFolder)
{
// Change annotation on the page in the PDF document.
await helper.UploadFile(documentName);
TextAnnotation annotation = await ReplaceAnnotation.GetAnnotationAsync(helper, documentName, annotationId, remoteFolder);
annotation.Contents = helper.config.REPLACED_CONTENT;
annotation.Icon = TextIcon.Star;
TextAnnotationResponse response = await helper.pdfApi.PutTextAnnotationAsync(documentName, annotationId, annotation, folder: remoteFolder);
if (response == null)
Console.WriteLine("ModifyAnnotation(): Unexpected error!");
else if (response.Code < 200 || response.Code > 299)
Console.WriteLine("ModifyAnnotation(): Failed to request text annotation from the document.");
else
{
Console.WriteLine("ModifyAnnotation(): annotation '{0}' successfully modified in the document '{1}.", annotationId, documentName);
await helper.DownloadFile(documentName, outputName, "replaced_annotatiom_");
}
}
}
}