Mark all 'Adobe' images with 'EMBED'
This commit is contained in:
parent
bbf37ef1f1
commit
ca651eca4d
12
pdf.js
12
pdf.js
@ -904,16 +904,16 @@ var PredictorStream = (function predictorStream() {
|
|||||||
// A JpegStream can't be read directly. We use the platform to render
|
// A JpegStream can't be read directly. We use the platform to render
|
||||||
// the underlying JPEG data for us.
|
// the underlying JPEG data for us.
|
||||||
var JpegStream = (function jpegStream() {
|
var JpegStream = (function jpegStream() {
|
||||||
function isYcckImage(bytes) {
|
function isAdobeImage(bytes) {
|
||||||
var maxBytesScanned = Math.max(bytes.length - 16, 1024);
|
var maxBytesScanned = Math.max(bytes.length - 16, 1024);
|
||||||
// Looking for APP14, 'Adobe' and transform = 2
|
// Looking for APP14, 'Adobe'
|
||||||
for (var i = 0; i < maxBytesScanned; ++i) {
|
for (var i = 0; i < maxBytesScanned; ++i) {
|
||||||
if (bytes[i] == 0xFF && bytes[i + 1] == 0xEE &&
|
if (bytes[i] == 0xFF && bytes[i + 1] == 0xEE &&
|
||||||
bytes[i + 2] == 0x00 && bytes[i + 3] == 0x0E &&
|
bytes[i + 2] == 0x00 && bytes[i + 3] == 0x0E &&
|
||||||
bytes[i + 4] == 0x41 && bytes[i + 5] == 0x64 &&
|
bytes[i + 4] == 0x41 && bytes[i + 5] == 0x64 &&
|
||||||
bytes[i + 6] == 0x6F && bytes[i + 7] == 0x62 &&
|
bytes[i + 6] == 0x6F && bytes[i + 7] == 0x62 &&
|
||||||
bytes[i + 8] == 0x65 && bytes[i + 9] == 0x00)
|
bytes[i + 8] == 0x65 && bytes[i + 9] == 0x00)
|
||||||
return bytes[i + 15] == 0x02;
|
return true;
|
||||||
// scanning until frame tag
|
// scanning until frame tag
|
||||||
if (bytes[i] == 0xFF && bytes[i + 1] == 0xC0)
|
if (bytes[i] == 0xFF && bytes[i + 1] == 0xC0)
|
||||||
break;
|
break;
|
||||||
@ -921,7 +921,7 @@ var JpegStream = (function jpegStream() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fixYcckImage(bytes) {
|
function fixAdobeImage(bytes) {
|
||||||
// Inserting 'EMBED' marker after JPEG signature
|
// Inserting 'EMBED' marker after JPEG signature
|
||||||
var embedMarker = new Uint8Array([0xFF, 0xEC, 0, 8, 0x45, 0x4D, 0x42, 0x45,
|
var embedMarker = new Uint8Array([0xFF, 0xEC, 0, 8, 0x45, 0x4D, 0x42, 0x45,
|
||||||
0x44, 0]);
|
0x44, 0]);
|
||||||
@ -939,8 +939,8 @@ var JpegStream = (function jpegStream() {
|
|||||||
// need to be removed
|
// need to be removed
|
||||||
this.dict = dict;
|
this.dict = dict;
|
||||||
|
|
||||||
if (isYcckImage(bytes))
|
if (isAdobeImage(bytes))
|
||||||
bytes = fixYcckImage(bytes);
|
bytes = fixAdobeImage(bytes);
|
||||||
|
|
||||||
// create DOM image
|
// create DOM image
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user