/ PDF / PdfTemplate
Search results

PdfTemplate API in JavaScript PDF API control

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(50, 100, 100, 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, 0, 0, 100, 50);
// Add annotation to the page
page.annotations.add(annotation);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();

Properties

_originalSize number[]

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 number[]

Get the size of the PDF template. (Read only)