PdfTemplate
16 Dec 20251 minute to read
PdfTemplate class represents the template of the PDF.
// 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 normal appearance of the annotation
let normalAppearance: PdfTemplate = annotation.appearance.normal;
// 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
normalAppearance.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
_originalSize Size
Get the original size of the PDF template. (Read only)
Remarks: The _originalSize property is internal and provides access to the original dimensions of the PDF template.
graphics PdfGraphics
Get the graphics of the PDF template. (Read only)
size Size
Get the size of the PDF template. (Read only)