Merge pull request #9352 from Snuffleupagus/issue-9285
Attempt to actually resolve ColourSpace names in accordance with the specification (issue 9285)
This commit is contained in:
commit
d77fc8882a
@ -258,17 +258,7 @@ var ColorSpace = (function ColorSpaceClosure() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ColorSpace.parseToIR = function(cs, xref, res, pdfFunctionFactory) {
|
ColorSpace.parseToIR = function(cs, xref, res = null, pdfFunctionFactory) {
|
||||||
if (isName(cs)) {
|
|
||||||
var colorSpaces = res.get('ColorSpace');
|
|
||||||
if (isDict(colorSpaces)) {
|
|
||||||
var refcs = colorSpaces.get(cs.name);
|
|
||||||
if (refcs) {
|
|
||||||
cs = refcs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cs = xref.fetchIfRef(cs);
|
cs = xref.fetchIfRef(cs);
|
||||||
if (isName(cs)) {
|
if (isName(cs)) {
|
||||||
switch (cs.name) {
|
switch (cs.name) {
|
||||||
@ -284,6 +274,20 @@ var ColorSpace = (function ColorSpaceClosure() {
|
|||||||
case 'Pattern':
|
case 'Pattern':
|
||||||
return ['PatternCS', null];
|
return ['PatternCS', null];
|
||||||
default:
|
default:
|
||||||
|
if (isDict(res)) {
|
||||||
|
let colorSpaces = res.get('ColorSpace');
|
||||||
|
if (isDict(colorSpaces)) {
|
||||||
|
let resCS = colorSpaces.get(cs.name);
|
||||||
|
if (resCS) {
|
||||||
|
if (isName(resCS)) {
|
||||||
|
return ColorSpace.parseToIR(resCS, xref, res,
|
||||||
|
pdfFunctionFactory);
|
||||||
|
}
|
||||||
|
cs = resCS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
throw new FormatError(`unrecognized colorspace ${cs.name}`);
|
throw new FormatError(`unrecognized colorspace ${cs.name}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -412,6 +412,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
xref: this.xref,
|
xref: this.xref,
|
||||||
res: resources,
|
res: resources,
|
||||||
image,
|
image,
|
||||||
|
isInline: inline,
|
||||||
pdfFunctionFactory: this.pdfFunctionFactory,
|
pdfFunctionFactory: this.pdfFunctionFactory,
|
||||||
});
|
});
|
||||||
// We force the use of RGBA_32BPP images here, because we can't handle
|
// We force the use of RGBA_32BPP images here, because we can't handle
|
||||||
@ -464,6 +465,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
xref: this.xref,
|
xref: this.xref,
|
||||||
res: resources,
|
res: resources,
|
||||||
image,
|
image,
|
||||||
|
isInline: inline,
|
||||||
nativeDecoder: nativeImageDecoder,
|
nativeDecoder: nativeImageDecoder,
|
||||||
pdfFunctionFactory: this.pdfFunctionFactory,
|
pdfFunctionFactory: this.pdfFunctionFactory,
|
||||||
}).then((imageObj) => {
|
}).then((imageObj) => {
|
||||||
|
@ -75,8 +75,8 @@ var PDFImage = (function PDFImageClosure() {
|
|||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
function PDFImage({ xref, res, image, smask = null, mask = null,
|
function PDFImage({ xref, res, image, isInline = false, smask = null,
|
||||||
isMask = false, pdfFunctionFactory, }) {
|
mask = null, isMask = false, pdfFunctionFactory, }) {
|
||||||
this.image = image;
|
this.image = image;
|
||||||
var dict = image.dict;
|
var dict = image.dict;
|
||||||
if (dict.has('Filter')) {
|
if (dict.has('Filter')) {
|
||||||
@ -139,7 +139,8 @@ var PDFImage = (function PDFImageClosure() {
|
|||||||
'color components not supported.');
|
'color components not supported.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.colorSpace = ColorSpace.parse(colorSpace, xref, res,
|
let resources = isInline ? res : null;
|
||||||
|
this.colorSpace = ColorSpace.parse(colorSpace, xref, resources,
|
||||||
pdfFunctionFactory);
|
pdfFunctionFactory);
|
||||||
this.numComps = this.colorSpace.numComps;
|
this.numComps = this.colorSpace.numComps;
|
||||||
}
|
}
|
||||||
@ -167,6 +168,7 @@ var PDFImage = (function PDFImageClosure() {
|
|||||||
xref,
|
xref,
|
||||||
res,
|
res,
|
||||||
image: smask,
|
image: smask,
|
||||||
|
isInline,
|
||||||
pdfFunctionFactory,
|
pdfFunctionFactory,
|
||||||
});
|
});
|
||||||
} else if (mask) {
|
} else if (mask) {
|
||||||
@ -179,6 +181,7 @@ var PDFImage = (function PDFImageClosure() {
|
|||||||
xref,
|
xref,
|
||||||
res,
|
res,
|
||||||
image: mask,
|
image: mask,
|
||||||
|
isInline,
|
||||||
isMask: true,
|
isMask: true,
|
||||||
pdfFunctionFactory,
|
pdfFunctionFactory,
|
||||||
});
|
});
|
||||||
@ -193,7 +196,7 @@ var PDFImage = (function PDFImageClosure() {
|
|||||||
* Handles processing of image data and returns the Promise that is resolved
|
* Handles processing of image data and returns the Promise that is resolved
|
||||||
* with a PDFImage when the image is ready to be used.
|
* with a PDFImage when the image is ready to be used.
|
||||||
*/
|
*/
|
||||||
PDFImage.buildImage = function({ handler, xref, res, image,
|
PDFImage.buildImage = function({ handler, xref, res, image, isInline = false,
|
||||||
nativeDecoder = null,
|
nativeDecoder = null,
|
||||||
pdfFunctionFactory, }) {
|
pdfFunctionFactory, }) {
|
||||||
var imagePromise = handleImageData(image, nativeDecoder);
|
var imagePromise = handleImageData(image, nativeDecoder);
|
||||||
@ -227,6 +230,7 @@ var PDFImage = (function PDFImageClosure() {
|
|||||||
xref,
|
xref,
|
||||||
res,
|
res,
|
||||||
image: imageData,
|
image: imageData,
|
||||||
|
isInline,
|
||||||
smask: smaskData,
|
smask: smaskData,
|
||||||
mask: maskData,
|
mask: maskData,
|
||||||
pdfFunctionFactory,
|
pdfFunctionFactory,
|
||||||
|
1
test/pdfs/issue9285.pdf.link
Normal file
1
test/pdfs/issue9285.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://github.com/mozilla/pdf.js/files/1563256/4149180-355989.pdf
|
@ -741,6 +741,14 @@
|
|||||||
"link": false,
|
"link": false,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
|
{ "id": "issue9285",
|
||||||
|
"file": "pdfs/issue9285.pdf",
|
||||||
|
"md5": "aa53ad98a72fd76c414101927951448b",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": true,
|
||||||
|
"lastPage": 1,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
{ "id": "issue8707",
|
{ "id": "issue8707",
|
||||||
"file": "pdfs/issue8707.pdf",
|
"file": "pdfs/issue8707.pdf",
|
||||||
"md5": "d3dc670adde9ec9fb82c974027033029",
|
"md5": "d3dc670adde9ec9fb82c974027033029",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user