Stop warning for non-Name /Filter entries in the PDFImage
constructor (PR 9897 follow-up)
Fixes a stupid oversight on my part, since /Filter may (obviously) contain an Array, which resulted in unnecessary console warning spam in perfectly valid PDF files. Note that it still makes sense to check that /Filter is actually a Name, before attempting to access its `name` property, but the warning should definitely be removed.
This commit is contained in:
parent
8a4be24645
commit
a504befc76
@ -83,27 +83,24 @@ var PDFImage = (function PDFImageClosure() {
|
|||||||
mask = 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')) {
|
|
||||||
const filter = dict.get('Filter');
|
|
||||||
if (isName(filter)) {
|
|
||||||
switch (filter.name) {
|
|
||||||
case 'JPXDecode':
|
|
||||||
var jpxImage = new JpxImage();
|
|
||||||
jpxImage.parseImageProperties(image.stream);
|
|
||||||
image.stream.reset();
|
|
||||||
|
|
||||||
image.width = jpxImage.width;
|
const filter = dict.get('Filter');
|
||||||
image.height = jpxImage.height;
|
if (isName(filter)) {
|
||||||
image.bitsPerComponent = jpxImage.bitsPerComponent;
|
switch (filter.name) {
|
||||||
image.numComps = jpxImage.componentsCount;
|
case 'JPXDecode':
|
||||||
break;
|
var jpxImage = new JpxImage();
|
||||||
case 'JBIG2Decode':
|
jpxImage.parseImageProperties(image.stream);
|
||||||
image.bitsPerComponent = 1;
|
image.stream.reset();
|
||||||
image.numComps = 1;
|
|
||||||
break;
|
image.width = jpxImage.width;
|
||||||
}
|
image.height = jpxImage.height;
|
||||||
} else {
|
image.bitsPerComponent = jpxImage.bitsPerComponent;
|
||||||
warn(`PDFImage - invalid /Filter entry in dictionary: "${filter}".`);
|
image.numComps = jpxImage.componentsCount;
|
||||||
|
break;
|
||||||
|
case 'JBIG2Decode':
|
||||||
|
image.bitsPerComponent = 1;
|
||||||
|
image.numComps = 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO cache rendered images?
|
// TODO cache rendered images?
|
||||||
|
Loading…
Reference in New Issue
Block a user