/ PDF / PdfImage
Search results

PdfImage API in JavaScript PDF API control

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, 10, 20, 400, 400);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();

Properties

height number

Gets the height of the PDF image.

physicalDimension number[]

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.
x number The x-coordinate of the image
y number The y-coordinate of the image.

Returns void