Implements the print permission
This commit is contained in:
parent
51c81a1d01
commit
729b82359a
@ -542,6 +542,7 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||||||
var docInfo = {
|
var docInfo = {
|
||||||
PDFFormatVersion: this.pdfFormatVersion,
|
PDFFormatVersion: this.pdfFormatVersion,
|
||||||
IsTextCopyDisabled: encrypt ? encrypt.disableTextCopy : false,
|
IsTextCopyDisabled: encrypt ? encrypt.disableTextCopy : false,
|
||||||
|
IsPrintDisabled: encrypt ? encrypt.disablePrint : false,
|
||||||
IsAcroFormPresent: !!this.acroForm
|
IsAcroFormPresent: !!this.acroForm
|
||||||
};
|
};
|
||||||
if (this.xref.trailer.has('Info')) {
|
if (this.xref.trailer.has('Info')) {
|
||||||
|
@ -562,6 +562,7 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {
|
|||||||
var userPassword = stringToBytes(dict.get('U'));
|
var userPassword = stringToBytes(dict.get('U'));
|
||||||
var flags = dict.get('P');
|
var flags = dict.get('P');
|
||||||
this.disableTextCopy = !(flags & 16);
|
this.disableTextCopy = !(flags & 16);
|
||||||
|
this.disablePrint = !(flags & 4);
|
||||||
var revision = dict.get('R');
|
var revision = dict.get('R');
|
||||||
var encryptMetadata = algorithm == 4 && // meaningful when V is 4
|
var encryptMetadata = algorithm == 4 && // meaningful when V is 4
|
||||||
dict.get('EncryptMetadata') !== false; // makes true as default value
|
dict.get('EncryptMetadata') !== false; // makes true as default value
|
||||||
|
@ -1358,6 +1358,10 @@ canvas {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#viewerContainer.print-protection {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.page {
|
.page {
|
||||||
float: left;
|
float: left;
|
||||||
display: none;
|
display: none;
|
||||||
|
@ -1360,6 +1360,20 @@ var PDFView = {
|
|||||||
document.getElementById('viewerContainer').classList
|
document.getElementById('viewerContainer').classList
|
||||||
.remove('copy-protection');
|
.remove('copy-protection');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (info.IsPrintDisabled) {
|
||||||
|
if (PDFView.supportsPrinting) {
|
||||||
|
document.getElementById('print').classList.add('hidden');
|
||||||
|
}
|
||||||
|
document.getElementById('viewerContainer').classList
|
||||||
|
.add('print-protection');
|
||||||
|
} else {
|
||||||
|
if (PDFView.supportsPrinting) {
|
||||||
|
document.getElementById('print').classList.remove('hidden');
|
||||||
|
}
|
||||||
|
document.getElementById('viewerContainer').classList
|
||||||
|
.remove('print-protection');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1626,6 +1640,9 @@ var PDFView = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
beforePrint: function pdfViewSetupBeforePrint() {
|
beforePrint: function pdfViewSetupBeforePrint() {
|
||||||
|
if (this.documentInfo.IsPrintDisabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!this.supportsPrinting) {
|
if (!this.supportsPrinting) {
|
||||||
var printMessage = mozL10n.get('printing_not_supported', null,
|
var printMessage = mozL10n.get('printing_not_supported', null,
|
||||||
'Warning: Printing is not fully supported by this browser.');
|
'Warning: Printing is not fully supported by this browser.');
|
||||||
|
Loading…
Reference in New Issue
Block a user