mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
Fallback to the built-in JPEG decoder if 'JpegStream', in src/display/api.js
, fails to load the image
This works by making `PartialEvaluator.buildPaintImageXObject` wait for the success/failure of `loadJpegStream` on the API side *before* parsing continues. Please note that in practice, it should be quite rare for the browser to fail loading/decoding of a JPEG image. In the general case, it should thus not be completely surprising if even `src/core/jpg.js` will fail to decode the image.
This commit is contained in:
parent
76afe1018b
commit
80441346a3
2 changed files with 43 additions and 19 deletions
|
@ -1817,22 +1817,22 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||
switch (type) {
|
||||
case 'JpegStream':
|
||||
imageData = data[3];
|
||||
new Promise((resolve, reject) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const img = new Image();
|
||||
img.onload = function() {
|
||||
resolve(img);
|
||||
};
|
||||
img.onerror = function() {
|
||||
reject(new Error('Error during JPEG image loading'));
|
||||
// Note that when the browser image loading/decoding fails,
|
||||
// we'll fallback to the built-in PDF.js JPEG decoder; see
|
||||
// `PartialEvaluator.buildPaintImageXObject` in the
|
||||
// `src/core/evaluator.js` file.
|
||||
};
|
||||
img.src = imageData;
|
||||
}).then((img) => {
|
||||
pageProxy.objs.resolve(id, img);
|
||||
}, (reason) => {
|
||||
warn(reason);
|
||||
pageProxy.objs.resolve(id, null);
|
||||
});
|
||||
break;
|
||||
case 'Image':
|
||||
imageData = data[3];
|
||||
pageProxy.objs.resolve(id, imageData);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue