IronSecureDoc 操作指南 使用者密碼與權限 How to Encrypt/Add Password & Permissions to PDF Files Curtis Chau 更新日期:7月 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,該 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 文件、使用者和擁有者的密碼以及如打印和編輯等操作的權限。這些參數確保了文檔的安全以及對其使用的控制。 在使用 IronSecureDoc 進行加密時可以修改 PDF 的元數據嗎? 是的,您可以使用 IronSecureDoc API 的可選參數來修改 PDF 的元數據,例如作者、標題和主題,允許您在加密過程中自訂文檔的資訊。 在本地運行 IronSecureDoc 的托管要求是什麼? IronSecureDoc 可以在 Windows、Mac 或 Linux 系統上本地托管。遵循特定的設置教程,確保服務的正確安裝和運行。 Curtis Chau 立即與工程團隊聊天 技術作家 Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。 準備好開始了嗎? 版本: 2024.10 剛剛發布 免費下載 查看許可證