PdfImage
16 Dec 20251 minute to read
The ‘PdfImage’ contains methods and properties to handle the images.
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Access first page
let page: PdfPage = document.getPage(0);
// Gets the graphics of the PDF page
let graphics: PdfGraphics = page.graphics;
// 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.
graphics.drawImage(image, {x: 10, y: 20, width: 400, height: 400});
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();Properties
height number
Gets the height of the PDF image.
physicalDimension Size
Gets the physical dimension of the PDF image (Read only).
width number
Gets the width of the PDF image.
Methods
draw
Represents a method to draw a image on the PDF graphics.
| Parameter | Type | Description |
|---|---|---|
| graphics | PdfGraphics |
value. |
Returns void
draw
Represents a method to draw a image on the PDF graphics.
| Parameter | Type | Description |
|---|---|---|
| graphics | PdfGraphics |
value. |
| location | Point |
The (x, y) coordinates of the image |
Returns void