* Embed an image (JPEG or PNG) into the document. * * Automatically detects the image format and calls the appropriate * embedding method. The returned PDFImage can be drawn on pages * using `page.drawImage()`. * * @param bytes - Image file bytes (JPEG or PNG) * @returns PDFImag
(bytes: Uint8Array)
| 2096 | * ``` |
| 2097 | */ |
| 2098 | embedImage(bytes: Uint8Array): PDFImage { |
| 2099 | if (isJpeg(bytes)) { |
| 2100 | return this.embedJpeg(bytes); |
| 2101 | } |
| 2102 | |
| 2103 | if (isPng(bytes)) { |
| 2104 | return this.embedPng(bytes); |
| 2105 | } |
| 2106 | |
| 2107 | throw new Error("Unsupported image format. Only JPEG and PNG are supported."); |
| 2108 | } |
| 2109 | |
| 2110 | /** |
| 2111 | * Embed a JPEG image into the document. |
no test coverage detected