HelpBot Assistant

How can I help you?

PdfAppearance

6 Feb 20261 minute to read

PdfAppearance class represents the appearance of the annotation.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the first page
let page: PdfPage = document.getPage(0) as PdfPage;
// Create a new rubber stamp annotation
const annotation: PdfRubberStampAnnotation = new PdfRubberStampAnnotation({x: 50, y: 100, width: 100, height: 50});
// Get the appearance of the annotation
let appearance: PdfAppearance = annotation.appearance;
// Create new image object by using JPEG image data as Base64 string format
let image: PdfImage = new PdfBitmap('/9j/4AAQSkZJRgABAQEAkACQAAD/4....QB//Z');
// Draw the image as the custom appearance for the annotation
appearance.normal.graphics.drawImage(image, {x: 0, y: 0, width: 100, height: 50});
// Add annotation to the page
page.annotations.add(annotation);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();

Properties

Get normal PdfTemplate

Get the normal appearance of the annotation.

Set normal void

Set the normal appearance of the annotation.

Parameter Type Description
value PdfTemplate The normal appearance of the annotation.