Merge pull request #9470 from Snuffleupagus/issue-4888
Ensure that `JpegImage.getData` returns the correct data length when `forceRGBoutput == true` (issue 4888)
This commit is contained in:
commit
a89071bdef
@ -1083,7 +1083,8 @@ var JpegImage = (function JpegImageClosure() {
|
|||||||
0.116935020465145) +
|
0.116935020465145) +
|
||||||
k * (-0.000343531996510555 * k + 0.24165260232407);
|
k * (-0.000343531996510555 * k + 0.24165260232407);
|
||||||
}
|
}
|
||||||
return data;
|
// Ensure that only the converted RGB data is returned.
|
||||||
|
return data.subarray(0, offset);
|
||||||
},
|
},
|
||||||
|
|
||||||
_convertYcckToCmyk: function convertYcckToCmyk(data) {
|
_convertYcckToCmyk: function convertYcckToCmyk(data) {
|
||||||
@ -1140,7 +1141,8 @@ var JpegImage = (function JpegImageClosure() {
|
|||||||
193.58209356861505) -
|
193.58209356861505) -
|
||||||
k * (22.33816807309886 * k + 180.12613974708367);
|
k * (22.33816807309886 * k + 180.12613974708367);
|
||||||
}
|
}
|
||||||
return data;
|
// Ensure that only the converted RGB data is returned.
|
||||||
|
return data.subarray(0, offset);
|
||||||
},
|
},
|
||||||
|
|
||||||
getData: function getData(width, height, forceRGBoutput) {
|
getData: function getData(width, height, forceRGBoutput) {
|
||||||
|
@ -18,7 +18,7 @@ import {
|
|||||||
} from './test_utils';
|
} from './test_utils';
|
||||||
import {
|
import {
|
||||||
createPromiseCapability, FontType, InvalidPDFException, MissingPDFException,
|
createPromiseCapability, FontType, InvalidPDFException, MissingPDFException,
|
||||||
PasswordException, PasswordResponses, StreamType, stringToBytes
|
OPS, PasswordException, PasswordResponses, StreamType, stringToBytes
|
||||||
} from '../../src/shared/util';
|
} from '../../src/shared/util';
|
||||||
import {
|
import {
|
||||||
DOMCanvasFactory, RenderingCancelledException
|
DOMCanvasFactory, RenderingCancelledException
|
||||||
@ -1104,6 +1104,25 @@ describe('api', function() {
|
|||||||
done.fail(reason);
|
done.fail(reason);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it('gets operatorList with JPEG image (issue 4888)', function(done) {
|
||||||
|
let loadingTask = getDocument(buildGetDocumentParams('cmykjpeg.pdf'));
|
||||||
|
|
||||||
|
loadingTask.promise.then((pdfDoc) => {
|
||||||
|
pdfDoc.getPage(1).then((pdfPage) => {
|
||||||
|
pdfPage.getOperatorList().then((opList) => {
|
||||||
|
let imgIndex = opList.fnArray.indexOf(OPS.paintImageXObject);
|
||||||
|
let imgArgs = opList.argsArray[imgIndex];
|
||||||
|
let { data: imgData, } = pdfPage.objs.get(imgArgs[0]);
|
||||||
|
|
||||||
|
expect(imgData instanceof Uint8ClampedArray).toEqual(true);
|
||||||
|
expect(imgData.length).toEqual(90000);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}).catch(function (reason) {
|
||||||
|
done.fail(reason);
|
||||||
|
});
|
||||||
|
});
|
||||||
it('gets stats after parsing page', function (done) {
|
it('gets stats after parsing page', function (done) {
|
||||||
var promise = page.getOperatorList().then(function () {
|
var promise = page.getOperatorList().then(function () {
|
||||||
return pdfDocument.getStats();
|
return pdfDocument.getStats();
|
||||||
|
Loading…
Reference in New Issue
Block a user