MCPcopy Create free account
hub / github.com/LibPDF-js/core / removeProtection

Method removeProtection

src/api/pdf.ts:938–960  ·  view source on GitHub ↗

* Remove all encryption from the document. * * After calling this, the document will be saved without encryption. * Requires owner access, or user access with modify permission. * * @throws {PermissionDeniedError} If insufficient permissions to remove protection * * @example

()

Source from the content-addressed store, hash-verified

936 * ```
937 */
938 removeProtection(): void {
939 // For unencrypted documents, this is a no-op
940 if (!this.isEncrypted) {
941 return;
942 }
943
944 const handler = this.ctx.info.securityHandler;
945
946 if (!handler) {
947 return;
948 }
949
950 // Check permissions
951 if (!handler.hasOwnerAccess && !handler.permissions.modify) {
952 throw new PermissionDeniedError(
953 "Cannot remove protection: requires owner access or modify permission",
954 "modify",
955 );
956 }
957
958 // Mark that encryption should be removed on save
959 this._pendingSecurity = { action: "remove" };
960 }
961
962 /**
963 * Add or change document encryption.

Callers 4

mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected