HTML
JPG
PDF
XML
DOCX
PDF
Add strikeout text annotations to PDF documents via .NET SDK
API for adding strikeout text annotations to PDF documents using Aspose.PDF Cloud .NET SDK.
Get StartedHow to imsert strikeout text annotations to PDF documents using Cloud .NET SDK
In order to add strikeout annotations to PDF documents via Cloud .NET SDK , we’ll use Aspose.PDF Cloud .NET SDK This Cloud SDK allows you to easily build cloud-based PDF creator, editor & converter apps in C#, ASP.NET, or other .NET languages for various cloud platforms. Open NuGet package manager, search for Aspose.PDF Cloud and install. You may also use the following command from the Package Manager Console.
Package Manager Console Command
PM> Install-Package Aspose.Pdf-Cloud
Steps to add annotations using .NET SDK
Aspose.PDF Cloud developers can easily load & append annotations to PDF documents in just a few lines of code.
- Uploads the input PDF.
- Creates a new StrikeOutAnnotation with properties like position, color, and text.
- Adds it to the desired page using Aspose.PDF Cloud API.
- Validates the response.
- Downloads the updated document locally.
This sample code shows adding annotations to PDF document
public static async Task AddStrikeoutAnnotation()
{
const string localPdfDocumentName = @"C:\Samples\sample.pdf";
const string storageFileName = "sample.pdf";
const string localFolder = @"C:\\Samples";
const string resultFileName = "output_add_so_annotation.pdf";
const int pageNumber = 1;
// Get your AppSid and AppSecret from https://dashboard.aspose.cloud (free registration required).
var pdfApi = new PdfApi(AppSecret, AppSid);
var filesOnStorage = await pdfApi.GetFilesListAsync("");
if (filesOnStorage.Value.All(f => f.Name != storageFileName))
{
using var file = File.OpenRead(localPdfDocumentName);
var uploadResult = await pdfApi.UploadFileAsync(storageFileName, file);
Console.WriteLine(uploadResult.Uploaded[0]);
}
List<StrikeOutAnnotation> annotations = new List<StrikeOutAnnotation>
{
new StrikeOutAnnotation(
Name: "Strikeout_NEW_Annotation",
Rect: new Rectangle(100,350, 450,400),
Flags: new List<AnnotationFlags>() { AnnotationFlags.Default },
HorizontalAlignment: HorizontalAlignment.Left,
VerticalAlignment: VerticalAlignment.Top,
RichText: "NEW STRIKEOUT TEXT ANNOTATION",
Subject: "Strikeout Text Box Subject",
Contents: "Strikeout annotation sample content",
Title: "This is a sample strikeout annotation",
ZIndex: 1,
Color: new Color(A: 0xFF, R: 0x00, G: 0xFF, B: 0x00),
QuadPoints: new List<Point>() {
new Point(X: 10, Y: 10),
new Point(X: 20, Y: 10),
new Point(X: 10, Y: 20),
new Point(X: 10, Y: 10)
},
Modified: "03/27/2025 00:00:00.000 AM"
)
};
AsposeResponse response = await pdfApi.PostPageStrikeOutAnnotationsAsync(storageFileName, pageNumber, annotations);
if (response == null)
Console.WriteLine("NewStrikeoutAnnotation(): Unexpected error!");
else if (response.Code < 200 || response.Code > 299)
Console.WriteLine("NewStrikeoutAnnotation(): Failed to append strikeout annotation to the document.");
else
{
await (await pdfApi.DownloadFileAsync(storageFileName))
.CopyToAsync(File.Create(Path.Combine(localFolder, resultFileName)));
Console.WriteLine("NewStrikeoutAnnotation(): annotation added to the document '{0}.", resultFileName);
}
}