Hosting on Windows

This article was translated from English: Does it need improvement?
Translated
View the article in English
IronSecureDoc on Docker

IronSecureDoc is a Docker container designed to give you powerful PDF manipulation behind a simple REST API, without the hassle and overhead of online SaaS services. This guide will walk you through the steps to host IronSecureDoc on your machine, including setting up environment variables and a basic example of using the REST API. For the full API, view our REST API Reference

docker pull ironsoftwareofficial/ironsecuredoc:latest
docker pull ironsoftwareofficial/ironsecuredoc:latest
SHELL

Prerequisites

Step-by-Step Guide

1. Install Docker Desktop

If you haven't already installed Docker Desktop, follow these steps:

  1. Go to the Docker Desktop download page.
  2. Download the Docker Desktop installer for Windows.
  3. Run the installer and follow the on-screen instructions.
  4. After installation, start Docker Desktop and make sure it's running.

2. Pull the "IronSecureDoc" Docker Image

Open a command prompt and pull the latest IronSecureDoc image from Docker Hub:

docker pull ironsoftwareofficial/ironsecuredoc:latest
docker pull ironsoftwareofficial/ironsecuredoc:latest
SHELL

3. Run the Container Without Certificate

Run the Docker container with the necessary environment variables:

Swagger UI in Browser
docker container run --rm -p 8080:8080 -e IronSecureDoc_LicenseKey=<IRONSECUREDOC_LICENSE_KEY> -e ENVIRONMENT=Development -e HTTP_PORTS=8080 ironsoftwareofficial/ironsecuredoc:latest
docker container run --rm -p 8080:8080 -e IronSecureDoc_LicenseKey=<IRONSECUREDOC_LICENSE_KEY> -e ENVIRONMENT=Development -e HTTP_PORTS=8080 ironsoftwareofficial/ironsecuredoc:latest
SHELL

Apply a Trial or License Key to Remove Watermarks

提示Replace <IRONSECUREDOC_LICENSE_KEY> with your actual IronSecureDoc license key. Otherwise, a watermark will be applied on Enterprise Features.

Swagger UI in Browser

4. Access the Container

Once the container is running, you can access IronSecureDoc by opening a web browser and navigating to:

http://localhost:8080/swagger/index.html
Swagger UI in Browser

You should see the IronSecureDoc interface, indicating that your container is running successfully.

5. Run the IronSecureDoc Container With Certificate

If you need to run the container with a certificate, follow these steps to generate the certificate and configure the local machine:

  1. Generate Certificate:

    dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\ironsecuredoc.pfx -p <CREDENTIAL_PLACEHOLDER>
    dotnet dev-certs https --trust
    dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\ironsecuredoc.pfx -p <CREDENTIAL_PLACEHOLDER>
    dotnet dev-certs https --trust
    SHELL

    Replace <CREDENTIAL_PLACEHOLDER> with a password.

  2. Run the Docker Container:

    docker container run -d -p 8081:8081 -p 8080:8080 -e HTTP_PORTS=8080 -e HTTPS_PORTS=8081 -e IronSecureDoc_LicenseKey=<IRONSECUREDOC_LICENSE_KEY> -e ENVIRONMENT=Production -v %USERPROFILE%\.aspnet\https:/https:ro -e CERTIFICATE_PATH=%USERPROFILE%\.aspnet\https\ironsecuredoc.pfx -e CERTIFICATE_PASSWORD=<CERTIFICATE_PASSWORD> ironsoftwareofficial/ironsecuredoc:latest
    docker container run -d -p 8081:8081 -p 8080:8080 -e HTTP_PORTS=8080 -e HTTPS_PORTS=8081 -e IronSecureDoc_LicenseKey=<IRONSECUREDOC_LICENSE_KEY> -e ENVIRONMENT=Production -v %USERPROFILE%\.aspnet\https:/https:ro -e CERTIFICATE_PATH=%USERPROFILE%\.aspnet\https\ironsecuredoc.pfx -e CERTIFICATE_PASSWORD=<CERTIFICATE_PASSWORD> ironsoftwareofficial/ironsecuredoc:latest
    SHELL

    Replace <IRONSECUREDOC_LICENSE_KEY> and <CERTIFICATE_PASSWORD> with your actual IronSecureDoc license key and certificate password respectively.

6. Managing the Container

You can manage your running container using Docker commands. Here are a few useful commands:

  • Stop the container:

    docker stop <container-id>
    docker stop <container-id>
    SHELL
  • Start the container:

    docker start <container-id>
    docker start <container-id>
    SHELL
  • Remove the container:

    docker rm -f <container-id>
    docker rm -f <container-id>
    SHELL

Replace <container-id> with the actual container ID or name.

Environment Variables

The container can be configured using the following environment variables:

  • PDF_MAX_SIZE_MB (Default: 30): Sets the maximum allowed file size for PDF uploads in Megabytes.
  • REQUEST_TIMEOUT_SECONDS (Default: 5): Sets the timeout duration in seconds for API requests. A value of -1 allows requests to run indefinitely.
  • ALLOWED_ORIGINS: Configures Cross-Origin Resource Sharing (CORS) by specifying allowed origin URLs. Separate multiple URLs with commas. Use * or all to allow requests from any origin.
  • HTTP_PORTS: Defines the HTTP ports the container exposes. This should match the port mapping using -p flag (e.g., 8080). Separate multiple ports with a semicolon (;).
  • HTTPS_PORTS: Defines the HTTPS ports the container exposes. This should match the port mapping using -p flag (e.g., 8081). Separate multiple ports with a semicolon (;).
  • IronSecureDoc_LicenseKey (Required): Sets the IronSecureDoc license key. Important: Do not share this value publicly.

Basic Example: Redact Text in a Document

For the full list of API endpoints, refer to the full REST API Reference.

Redact Text

curl -X POST 'http://localhost:8080/v1/document-services/pdfs/redact-text' -H 'accept: */*' -H 'Content-Type: multipart/form-data' -F 'pdf_file=@/path/to/your/document.pdf;type=application/pdf' -F 'words_to_redact="sensitiveWord"' -F 'draw_black_box=true' -F 'match_whole_word=true' -F 'match_case=true'
curl -X POST 'http://localhost:8080/v1/document-services/pdfs/redact-text' -H 'accept: */*' -H 'Content-Type: multipart/form-data' -F 'pdf_file=@/path/to/your/document.pdf;type=application/pdf' -F 'words_to_redact="sensitiveWord"' -F 'draw_black_box=true' -F 'match_whole_word=true' -F 'match_case=true'
SHELL

Replace /path/to/your/document.pdf with the actual path to the document you want to redact and sensitiveWord with the word you want to redact.

Redact Regular Expression

curl -X POST 'http://localhost:8080/v1/document-services/pdfs/redact-regular-expression' -H 'accept: */*' -H 'Content-Type: multipart/form-data' -F 'pdf_file=@/path/to/your/document.pdf;type=application/pdf' -F 'regular_expression="[0-9]"' -F 'draw_black_box=true'
curl -X POST 'http://localhost:8080/v1/document-services/pdfs/redact-regular-expression' -H 'accept: */*' -H 'Content-Type: multipart/form-data' -F 'pdf_file=@/path/to/your/document.pdf;type=application/pdf' -F 'regular_expression="[0-9]"' -F 'draw_black_box=true'
SHELL

Replace /path/to/your/document.pdf with the actual path to the document you want to redact and [0-9] with the regular expression you want to match and redact.

Conclusion

You have successfully hosted IronSecureDoc on your machine and configured it with necessary environment variables. You also learned how to interact with the IronSecureDoc REST API using cURL for both basic and advanced operations. For further configuration and usage details, refer to the full REST API Reference.

常见问题解答

什么是 IronSecureDoc?

IronSecureDoc 是一个 Docker 容器,通过简单的 REST API 提供强大的 PDF 操作,专为离线文档安全和合规而设计。

在 Windows 上托管 IronSecureDoc 的系统要求是什么?

要在 Windows 上托管 IronSecureDoc,您需要 Windows 10 或更高版本,或 Windows Server 版本(2016、2019、2022)并安装适用于 Windows 的 Docker Desktop。

如何在我的 Windows 机器上安装 Docker Desktop?

从 Docker 的官方网站下载 Docker Desktop,运行安装程序,并按照安装说明进行操作。安装完成后,启动 Docker Desktop 以开始使用。

如何下载 IronSecureDoc Docker 映像?

打开您的命令提示符并执行命令:docker pull ironsoftwareofficial/ironsecuredoc:latest 以下载 IronSecureDoc 映像。

是否可以在没有 SSL 证书的情况下运行 IronSecureDoc?

是的,您可以通过执行命令来运行不带 SSL 证书的 IronSecureDoc 容器:docker container run --rm -p 8080:8080 -e IronSecureDoc_LicenseKey= -e ENVIRONMENT=Development -e HTTP_PORTS=8080 ironsoftwareofficial/ironsecuredoc:latest,将 替换为您的实际许可证密钥。

容器运行后如何访问 IronSecureDoc 界面?

您可以打开网络浏览器并导航到 http://localhost:8080/swagger/index.html 来访问 IronSecureDoc 界面。

如何使用 SSL 证书配置 IronSecureDoc?

使用 dotnet dev-certs 生成证书,然后使用包含证书路径和密码的命令运行 IronSecureDoc 容器,以增强安全性。

哪些环境变量可用于配置 IronSecureDoc 容器?

您可以配置各种环境变量,例如 PDF_MAX_SIZE_MB、REQUEST_TIMEOUT_SECONDS、ALLOWED_ORIGINS、HTTP_PORTS、HTTPS_PORTS 和 IronSecureDoc_LicenseKey。

如何使用 IronSecureDoc 编辑 PDF 中的敏感信息?

要在 PDF 中编辑文本,请使用 cURL 命令发送 POST 请求到 IronSecureDoc REST API,指定 PDF 文件和要编辑的文本或模式。

在哪里可以找到详细的 IronSecureDoc REST API 文档?

完整的 IronSecureDoc REST API 参考位于 /enterprise/securedoc/tutorials/use-rest-api/

Curtis Chau
技术作家

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。

准备开始了吗?
版本: 2024.10 刚刚发布