diff --git a/base/shared/colorspace.js b/base/shared/colorspace.js index f60e47f..ede90db 100755 --- a/base/shared/colorspace.js +++ b/base/shared/colorspace.js @@ -212,7 +212,10 @@ var ColorSpace = (function ColorSpaceClosure() { case 'CMYK': return 'DeviceCmykCS'; case 'CalGray': - var params = cs[1].getAll(); + var params = xref.fetchIfRef(cs[1]); + if (isDict(params)) { + params = params.getAll(); + } return ['CalGrayCS', params]; case 'CalRGB': return 'DeviceRgbCS'; @@ -253,7 +256,10 @@ var ColorSpace = (function ColorSpaceClosure() { var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3])); return ['AlternateCS', numComps, alt, tintFnIR]; case 'Lab': - var params = cs[1].getAll(); + var params = xref.fetchIfRef(cs[1]); + if (isDict(params)) { + params = params.getAll(); + } return ['LabCS', params]; default: error('unimplemented color space object "' + mode + '"'); diff --git a/package.json b/package.json index b3b562d..c2d385f 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "test:jest": "jest --config ./jest.config.json --detectOpenHandles", "test": "npm run test:jest && npm run parse-r && npm run parse-fd && npm run test:deno && npm run test:bun", "test:forms": "cd ./test && sh p2j.forms.sh", - "test:misc": "cd ./test && sh p2j.one.sh misc . \"Expected: 15 success, 6 fail exception with stack trace\" ", + "test:misc": "cd ./test && sh p2j.one.sh misc . \"Expected: 16 success, 6 fail exception with stack trace\" ", "parse": "./bin/pdf2json.js -f ./test/pdf/fd/form/F1040.pdf -o ./test/target/fd/form", "parse-s": "./bin/pdf2json.js -f ./test/pdf/fd/form/F1040.pdf -o ./test/target/fd/form -s", "parse-t": "./bin/pdf2json.js -f ./test/pdf/fd/form/F1040.pdf -o ./test/target/fd/form -s -t", @@ -47,7 +47,7 @@ "parse-tb": "./bin/pdf2json.js -f ./test/pdf/misc/i242_testingWithTable.pdf -o ./test/target/misc", "parse-tc": "./bin/pdf2json.js -f ./test/pdf/misc/i293_pdfpac.pdf -o ./test/target/misc", "parse-rectFix": "./bin/pdf2json.js -f ./test/pdf/misc/pr298_rect_fix_from_upstream.pdf -o ./test/target/misc", - "parse-e": "./bin/pdf2json.js -f ./test/pdf/misc/i306_err_invalid.pdf -o ./test/target/misc", + "parse-e": "./bin/pdf2json.js -f ./test/pdf/misc/i418_precompilato_fake.pdf -o ./test/target/misc", "build:rollup": "npx rollup -c ./rollup.config.js", "build:bundle-pdfjs-base": "node rollup/bundle-pdfjs-base.js", "build": "npm run build:bundle-pdfjs-base && npm run build:rollup", @@ -68,8 +68,7 @@ "bin": { "pdf2json": "bin/pdf2json.js" }, - "dependencies": { - }, + "dependencies": {}, "bundleDependencies": [], "devDependencies": { "@eslint/js": "^9.37.0", @@ -122,4 +121,4 @@ "readme.md", "license.txt" ] -} +} \ No newline at end of file diff --git a/test/pdf/misc/i418_precompilato_fake.pdf b/test/pdf/misc/i418_precompilato_fake.pdf new file mode 100644 index 0000000..0627d41 Binary files /dev/null and b/test/pdf/misc/i418_precompilato_fake.pdf differ