How can I help you?
PdfImage
6 Feb 20262 minutes 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
Get height number
Gets the height of the PDF image.
Set height void
Sets the height of the PDF image.
| Parameter | Type | Description |
|---|---|---|
| value | number |
Value. |
Get physicalDimension Size
Gets the physical dimension of the PDF image (Read only).
Get width number
Gets the width of the PDF image.
Set width void
Sets the width of the PDF image.
| Parameter | Type | Description |
|---|---|---|
| value | number |
Value. |
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