IronSecureDoc 操作指南 密码和权限 How to Encrypt/Add Password & Permissions to PDF Files Curtis Chau 已更新:七月 22, 2025 Download IronSecureDoc 免费下载 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article This article was translated from English: Does it need improvement? Translated View the article in English Securing PDF files with passwords and specific permissions is vital for protecting sensitive documents from unauthorized access and manipulation. The [POST] Encrypt/Add Password & Permissions API from IronSecure Doc provides an efficient way to encrypt PDF files with user and owner passwords while configuring permissions for printing, form filling, annotations, and more. This API ensures that the PDF is fully protected and access is controlled, making it ideal for legal, financial, or personal documents. How to Encrypt/Add Password & Permissions to PDF Files Pull and start the IronSecureDoc Docker Image Test the API using Swagger Specify the parameters for password and permissions Execute the API call to apply the changes Export the encrypted PDF document Pull and Start IronSecureDoc If you don't have IronSecureDoc running yet, please follow the links below to get it set up: Host Locally Deploy to Cloud Hosting on Windows Hosting on Mac Hosting on Linux Deploy on Azure Container Deploy on AWS Container The [POST] Encrypt/Add Password & Permissions API The [POST] Encrypt/Add Password & Permissions API allows you to add security layers to PDF documents by encrypting them with passwords and setting specific permissions for various operations. Whether it's granting read access, allowing form filling, or disabling printing, this API gives you control over how your PDF files are accessed and modified. Swagger Swagger offers a user-friendly interface to test this API interactively. You can use it to send test requests and receive responses without writing code, making it a great tool for developers. Steps to Redact Text with Swagger Access the Swagger UI: If your API server is running locally, you can access Swagger by navigating to http://localhost:8080/swagger/index.html in your web browser. Locate the API: Find the [POST] /v1/document-services/pdfs/encrypt API, which corresponds to Encrypt/Add Password & Permissions. Input Parameters: Provide the required parameters for the API. You can upload a sample PDF file and specify the desired permissions. Upload PDF File: In the request body, upload a PDF file as pdf_file and define the necessary permissions, such as allowing or restricting printing, form filling, and content extraction. Execute the Request: Once all parameters are set, click "Execute" to send the request. The response will return the encrypted PDF with the specified security settings. Check the Output PDF: Type in 'password' to view the PDF content. This browser does not support PDFs. Please download the PDF to view it: Download PDF. Understanding Input Parameters The API requires specific parameters to encrypt the PDF and assign permissions. Below is a breakdown of both required and optional parameters: Required Parameters Name Data Type Description pdf_file application/pdf The PDF file you want to encrypt. allow_extracting_content boolean Indicate whether content extraction is allowed. allow_form_filling boolean Indicate whether form filling is allowed. allow_annotations boolean Indicate whether annotations are allowed. allow_printing boolean Indicate whether printing is allowed. allow_modifications boolean Indicate whether modifications are allowed. new_owner_password string The new owner password for the PDF, which grants full access and the ability to change permissions. Optional Parameters Name Data Type Description user_password string The current user password, required if the PDF has a user password to grant read access. owner_password string The current owner password, required if the PDF has an owner password to grant full access. new_user_password string The new user password for read access. save_as_pdfa boolean Save the PDF as PDF/A-3 compliant. save_as_pdfua boolean Save the PDF as PDF/UA compliant. author string Set the PDF metadata Author property. title string Set the PDF metadata Title property. subject string Set the PDF metadata Subject property. API Integration: Python Example Once you're familiar with the input parameters, you can call the API using Python or any other preferred language. Below is an example of how to integrate this API using Python. import requests # Endpoint URL url = 'http://localhost:8080/v1/document-services/pdfs/encrypt' # Headers with metadata information headers = { 'accept': '*/*', 'author': 'IronSoftware', 'title': 'ENCRYPTION DEMO 2024', 'subject': 'DEMO EXAMPLE' } # Files to be sent in the request files = { 'pdf_file': ('sample.pdf', open('sample.pdf', 'rb'), 'application/pdf') } # Parameters for encryption and permissions data = { 'allow_extracting_content': 'true', 'allow_form_filling': 'true', 'allow_annotations': 'false', 'allow_printing': 'false', 'allow_modifications': 'true', 'new_owner_password': 'password', 'new_user_password': 'password', 'save_as_pdfa': 'false', 'save_as_pdfua': 'false' } # Send POST request with parameters response = requests.post(url, headers=headers, files=files, data=data) # Save the encrypted PDF to file system with open('sample_encrypted.pdf', 'wb') as f: f.write(response.content) print('PDF encrypted successfully.') import requests # Endpoint URL url = 'http://localhost:8080/v1/document-services/pdfs/encrypt' # Headers with metadata information headers = { 'accept': '*/*', 'author': 'IronSoftware', 'title': 'ENCRYPTION DEMO 2024', 'subject': 'DEMO EXAMPLE' } # Files to be sent in the request files = { 'pdf_file': ('sample.pdf', open('sample.pdf', 'rb'), 'application/pdf') } # Parameters for encryption and permissions data = { 'allow_extracting_content': 'true', 'allow_form_filling': 'true', 'allow_annotations': 'false', 'allow_printing': 'false', 'allow_modifications': 'true', 'new_owner_password': 'password', 'new_user_password': 'password', 'save_as_pdfa': 'false', 'save_as_pdfua': 'false' } # Send POST request with parameters response = requests.post(url, headers=headers, files=files, data=data) # Save the encrypted PDF to file system with open('sample_encrypted.pdf', 'wb') as f: f.write(response.content) print('PDF encrypted successfully.') PYTHON Steps Explained: Load the PDF: The PDF file to be encrypted is loaded from the local file system. Set Encryption Parameters: Define permissions like allowing printing, form filling, and content extraction, as well as setting new passwords. Call the API: The [POST] Encrypt/Add Password & Permissions API is called, passing the necessary parameters. Save the Result: The encrypted PDF is saved as a new file. The PDF file is encrypted as shown below. Type in 'password' to view the PDF content. This browser does not support PDFs. Please download the PDF to view it: Download PDF. 常见问题解答 如何加密 PDF 文件以保护敏感信息? 要加密 PDF 文件,您可以使用 IronSecureDoc API,它允许您设置用户密码和所有者密码。这些密码帮助控制访问和权限,例如打印和填写表单,确保文档的安全性。 使用 IronSecureDoc API 进行 PDF 加密涉及哪些步骤? 首先,拉取 IronSecureDoc 的 Docker 镜像,并根据您的托管环境进行设置。接下来,使用 API 指定加密参数,例如设置密码和权限,并执行 API 调用以生成安全的 PDF。 如何在不编写代码的情况下测试 IronSecureDoc API? 您可以使用 Swagger 测试 IronSecureDoc API。访问 Swagger UI,找到相关的 API 端点,输入必要的参数,并执行请求以查看响应并确保 API 正常工作。 什么是 PDF 安全中的用户和所有者密码? 在 PDF 安全中,用户密码允许读取文档,而所有者密码授予完整访问权限,包括更改权限。使用 IronSecureDoc,您可以设置这两种类型的密码以增强文档安全性。 我可以使用 IronSecureDoc 将 PDF 配置为符合 PDF/A 吗? 是的,IronSecureDoc API 包含允许您将加密的 PDF 保存为符合 PDF/A-3 的参数,这是一种电子文档长期保存的标准。 可以通过 IronSecureDoc API 控制哪些权限? 使用 IronSecureDoc API,您可以控制打印、填写表单、内容提取、注释和修改等权限,确保 PDF 的使用符合您的安全策略。 如何将 IronSecureDoc API 与 Python 应用程序集成? 要将 IronSecureDoc API 与 Python 集成,利用 requests 库发送 POST 请求到 API 端点。在您的请求中包含必要的头信息、参数和文件数据以加密和管理您的 PDF 文件。 使用 IronSecureDoc 加密 PDF 需要哪些必需参数? 基本参数包括要加密的 PDF 文件、用户和所有者密码,以及打印和编辑等操作的权限。这些参数确保文档的安全性和对其使用的控制。 在加密时,是否可能修改 PDF 的元数据? 是的,您可以使用 IronSecureDoc API 的可选参数修改 PDF 元数据,例如作者、标题和主题,允许您在加密过程中自定义文档信息。 运行 IronSecureDoc 本地实例的托管要求是什么? IronSecureDoc 可以在 Windows、Mac 或 Linux 系统上本地托管。根据您的操作系统遵循特定的设置教程,以确保服务的正确安装和运行。 Curtis Chau 立即与工程团队聊天 技术作家 Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。 准备开始了吗? 版本: 2024.10 刚刚发布 免费下载 查看许可证