We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
imgArr: [ { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, { url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 }, ] for (const img of data.imgArr) { const imageBuffer = await fetch(img.url).then((res) => res.arrayBuffer()); const image = await pdfDoc.embedJpg(imageBuffer); const imgWidth = 300; const imgHeight = 150; const allWidth = (config.width - imgWidth) / 2; // 使图片居中 if (startY < imgHeight + 61.89) { // 如果剩余空间不足,重启一页 page = pdfDoc.addPage([config.width, config.height]); startY = config.startY; } page.drawImage(image, { x: allWidth, y: startY - imgHeight - 5, width: imgWidth, height: imgHeight, }); startY -= imgHeight + 6; // 图片下方留一些空隙
page.drawText(img.description, { x: (config.width - Font2.widthOfTextAtSize(img.description, config.size)) / 2, y: startY - 20, size: config.size, font: Font2, color: config.color, }); startY -= lineHeight; } 使用的是vue3,pdf-lib版本为1.17.1,图片数量一多就无法生成,不知道是什么原因,麻烦帮忙看看
The text was updated successfully, but these errors were encountered:
No branches or pull requests
imgArr: [
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
{ url: csJpg, description: '图 1.1-1 地理位置平面图', width: 800, height: 500 },
] for (const img of data.imgArr) {
const imageBuffer = await fetch(img.url).then((res) => res.arrayBuffer());
const image = await pdfDoc.embedJpg(imageBuffer);
const imgWidth = 300;
const imgHeight = 150;
const allWidth = (config.width - imgWidth) / 2; // 使图片居中
if (startY < imgHeight + 61.89) { // 如果剩余空间不足,重启一页
page = pdfDoc.addPage([config.width, config.height]);
startY = config.startY;
}
page.drawImage(image, {
x: allWidth,
y: startY - imgHeight - 5,
width: imgWidth,
height: imgHeight,
});
startY -= imgHeight + 6; // 图片下方留一些空隙
The text was updated successfully, but these errors were encountered: