我想使用javascript中的pdf-lib删除pdf文件中的特定图像。
var PDFDocument = PDFLib.PDFDocument;
const pdfBuffer = await fetch(pdf_url).then((res) => res.arrayBuffer())
const pdfDoc = await PDFDocument.load(pdfBuffer);
const firstPage = pdfDoc.getPages()[0];
const imageRef = firstPage
.get<PDFDictionary>('Resources')
.get<PDFDictionary>('XObject')
.get<PDFIndirectReference>('CatRidingUnicorn');
pdfDoc2.index.index.delete(imageRef);
const pdfBytes = await pdfDoc.save();