Fixes text search for "secured" documents
This commit is contained in:
parent
3699c311bb
commit
d5f65f5431
@ -298,7 +298,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
||||
}
|
||||
|
||||
var gfx = new CanvasGraphics(params.canvasContext, this.commonObjs,
|
||||
this.objs, !this.pageInfo.disableTextLayer && params.textLayer);
|
||||
this.objs, params.textLayer);
|
||||
try {
|
||||
this.display(gfx, params.viewport, complete, continueCallback);
|
||||
} catch (e) {
|
||||
|
@ -538,8 +538,10 @@ var PDFDocument = (function PDFDocumentClosure() {
|
||||
return shadow(this, 'numPages', num);
|
||||
},
|
||||
getDocumentInfo: function PDFDocument_getDocumentInfo() {
|
||||
var encrypt = this.xref.encrypt;
|
||||
var docInfo = {
|
||||
PDFFormatVersion: this.pdfFormatVersion,
|
||||
IsTextCopyDisabled: encrypt ? encrypt.disableTextCopy : false,
|
||||
IsAcroFormPresent: !!this.acroForm
|
||||
};
|
||||
if (this.xref.trailer.has('Info')) {
|
||||
|
@ -561,7 +561,7 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {
|
||||
var ownerPassword = stringToBytes(dict.get('O'));
|
||||
var userPassword = stringToBytes(dict.get('U'));
|
||||
var flags = dict.get('P');
|
||||
this.disableTextLayer = !(flags & 16);
|
||||
this.disableTextCopy = !(flags & 16);
|
||||
var revision = dict.get('R');
|
||||
var encryptMetadata = algorithm == 4 && // meaningful when V is 4
|
||||
dict.get('EncryptMetadata') !== false; // makes true as default value
|
||||
|
@ -214,13 +214,11 @@ var WorkerMessageHandler = {
|
||||
handler.on('GetPageRequest', function wphSetupGetPage(data) {
|
||||
var pageNumber = data.pageIndex + 1;
|
||||
var pdfPage = pdfModel.getPage(pageNumber);
|
||||
var encrypt = pdfModel.xref.encrypt;
|
||||
var page = {
|
||||
pageIndex: data.pageIndex,
|
||||
rotate: pdfPage.rotate,
|
||||
ref: pdfPage.ref,
|
||||
view: pdfPage.view,
|
||||
disableTextLayer: encrypt ? encrypt.disableTextLayer : false
|
||||
view: pdfPage.view
|
||||
};
|
||||
handler.send('GetPage', {pageInfo: page});
|
||||
});
|
||||
|
@ -1198,6 +1198,14 @@ canvas {
|
||||
background-color: rgba(0, 100, 0, 0.2);
|
||||
}
|
||||
|
||||
#viewerContainer.copy-protection .textLayer > div {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
#viewerContainer.copy-protection .textLayer > div > .highlight {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
/* TODO: file FF bug to support ::-moz-selection:window-inactive
|
||||
so we can override the opaque grey background when the window is inactive;
|
||||
see https://bugzilla.mozilla.org/show_bug.cgi?id=706209 */
|
||||
|
@ -1350,6 +1350,14 @@ var PDFView = {
|
||||
// AcroForm/XFA was found
|
||||
PDFView.fallback();
|
||||
}
|
||||
|
||||
if (info.IsTextCopyDisabled) {
|
||||
document.getElementById('viewerContainer').classList
|
||||
.add('copy-protection');
|
||||
} else {
|
||||
document.getElementById('viewerContainer').classList
|
||||
.remove('copy-protection');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user