diff --git a/package.json b/package.json index f06975e..f55da62 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bsorrentino/pdf-tools", - "version": "1.1.0", + "version": "1.2.0", "description": "", "main": "index.js", "bin": { diff --git a/samples/User_Installation_Guide_oracle.pdf b/samples/User_Installation_Guide_oracle.pdf new file mode 100644 index 0000000..184b3f9 Binary files /dev/null and b/samples/User_Installation_Guide_oracle.pdf differ diff --git a/src/index.ts b/src/index.ts index c19a733..d5426c1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -68,13 +68,19 @@ async function extractImagesfromPages(pdfPath: string) { const ops = await page.getOperatorList() + const ImageFromOp = (op: string):PDFImage => + op.startsWith('g_') ? + page.commonObjs.get(op) : + page.objs.get(op); + + for (let j = 0; j < ops.fnArray.length; j++) { if (ops.fnArray[j] == OPS.paintJpegXObject || ops.fnArray[j] == OPS.paintImageXObject) { const op = ops.argsArray[j][0]; - - const img = page.objs.get(op) as PDFImage; + + const img = ImageFromOp(op); //const scale = img.width / page._pageInfo.view[2];