javascript - 在 pdf-lib 中设置 Pdf 图像注释的链接
问题描述
我有一个 Pdf 文件,我正在尝试在图像上添加图像和一个带有链接的矩形...
使用https://www.npmjs.com/package/pdf-lib
const pdfDoc = await PDFDocument.load(await pdf.getData());
const pages = pdfDoc.getPages()
const page = pages[index]
const pngImage = await pdfDoc.embedPng(pngImageBytes)
const pngDims = pngImage.scale(0.5)
// Draw the PNG image near the lower right corner of the JPG image
// x: page.getWidth() / 2 - pngDims.width / 2 + 75,
// y: page.getHeight() / 2 - pngDims.height,
page.drawImage(pngImage, {
x:coordinations.x - pngDims.width / 2,
y:coordinations.y - pngDims.height / 2,
width: pngDims.width,
height: pngDims.height,
})
const pdfBytes = await pdfDoc.save()
图像已创建,但我找不到通过图像上的链接创建矩形的方法
所以人们可以点击图片并打开链接....
解决方案
推荐阅读
- r - 有条件地将命名元素添加到列表中
- c++11 - enable_if 用法之间的区别
- function - 云功能部署问题
- jmeter - 如何用JMeter中的动态值替换具有特殊字符的文件内容
- python - 使用 scikit-fmm 或 gdist 在 3d 三角形网格上的测地线距离
- javascript - 如何在不使用 Angular Material 中的绝对位置的情况下将 mat-list-items 推到底部?
- javascript - 如何加载新的 html 页面并使用通过动态对象的 onclick 获得的元素?
- django - django 中的网络和移动身份验证
- node.js - Heroku Node.js WebSocket 服务器聊天部署
- c++ - 从基础向下向下推导