IRONSOFTWAREHOME
密码、安全性和元数据
import {PdfDocument} from "@ironsoftware/ironpdf";

(async () => {
    // Import a PDF document or create a new PDF from Html
    const pdf = await PdfDocument.open("encrypted.pdf", "password");

    // Create an empty Map
    const newMetadata = new Map();

    // Add key-value pairs of metadata
    newMetadata.set("Author", "Satoshi Nakamoto");
    newMetadata.set("Keywords", "SEO, Friendly");

    await pdf.overrideMetadata(newMetadata);

    await pdf.removePasswordsAndEncryption();
    // Make PDF read-only
    await pdf.makePdfDocumentReadOnly("secret-key");

    // Configure permissions
    const permissions = {
        AllowAnnotations: false,
        AllowExtractContent: false,
        AllowFillForms: false,
        AllowPrint: true,
    };

    await pdf.setPermission(permissions);
    
    // Change or set the document encrpytion password
    await pdf.saveAs("secured.pdf", {
        ownerPassword: "top-secret",
        userPassword: "my-password",
    });
})();
npm i @ironsoftware/ironpdf
密码、安全性和元数据

密码、安全性和元数据

IronPDF 允许加密、解密、修改元数据,并设置有关注释、复制和粘贴内容、表单字段和打印的某些权限。

要打开密码保护的PDF文档,请使用open方法并将密码作为第二个参数提供。 设置元数据需要创建一个新映射并输入对应于元数据信息的键值对。 将新的元数据映射传递给overrideMetadata方法以覆盖旧的元数据。

removePasswordsAndEncryption方法用于删除文档中的任何密码。 makePdfDocumentReadOnly方法将使此PDF文档只读,以128位加密内容,并禁止复制粘贴内容、注释和表单编辑。

通过创建具有权限设置的权限对象配置权限,并将其传递给setPermission方法。

最后,userPassword属性的对象。

有关 IronPDF 功能和用途的详细信息,请访问 IronPDF 产品页面,或在他们的网站上了解更多关于 Iron Software 其他产品的信息。

在 GitHub 上探索安全与元数据示例
在 GitHub 上查看

准备开始了吗?

版本:2026.6刚刚发布

Key in blue circle

立即获取免费的 30 天试用版密钥。

Your trial license will be sent to your email address

无任何限制。100% 解锁。无需信用卡。

OR
bullet_checked无需信用卡或创建账户无任何限制。100% 解锁。无需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
预约您的免费现场演示
Booking Badge

深受全球数百万工程师信赖

Iron Software 的客户徽标
获取您的无义务咨询
填写下面的表格或通过sales@ironsoftware.com
您的资料将始终保密。
深受全球数百万工程师信赖
Iron Software 的客户徽标
立即获取您的免费30 天试用密钥。
无需信用卡或创建账户
Node.js 模块下载用于 PDF
using npm 安装

版本: 2026.6

  1. 下载并安装 Node.js 12+。
  2. 在终端中执行上述命令。

$999 起