Host IronSecureDoc on Mac with C# API
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.
# Pull the latest IronSecureDoc Docker image
docker pull ironsoftwareofficial/ironsecuredoc:latest
Prerequisites
Mac with Intel chip
- Docker Desktop for Mac with Intel chip installed and running
Mac with Apple silicon
- Docker Desktop for Mac with Apple silicon installed and running
Step-by-Step Guide
1. Install Docker Desktop
If you haven't already installed Docker Desktop, follow these steps:
- Go to the Docker Desktop download page.
- Download the Docker Desktop installer for Mac.
- Run the installer and follow the on-screen instructions.
- After installation, start Docker Desktop and make sure it's running.
2. Pull the "IronSecureDoc" Docker Image
Open a command line interface and pull the latest IronSecureDoc image from Docker Hub:
# Pull the latest IronSecureDoc image
docker pull ironsoftwareofficial/ironsecuredoc:latest
3. Run the Container Without Certificate
Run the Docker container with the necessary environment variables:
# Run the Docker container with environment variables
docker container run --rm -p 8080:8080 \
-e IronSecureDoc_LicenseKey=<IRONSECUREDOC_LICENSE_KEY> \
-e ENVIRONMENT=Development \
-e HTTP_PORTS=8080 \
ironsoftwareofficial/ironsecuredoc:latest
Replace <IRONSECUREDOC_LICENSE_KEY> with your actual IronSecureDoc license key. Otherwise, a watermark will be applied on Enterprise Features.
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
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:
-
Generate Certificate:
# Generate and trust HTTPS development certificate dotnet dev-certs https -ep $HOME/.aspnet/https/ironsecuredoc.pfx -p <CREDENTIAL_PLACEHOLDER> dotnet dev-certs https --trustSHELL
Replace <CREDENTIAL_PLACEHOLDER> with a password.
-
Run the Docker Container:
# Run the container with HTTPS support 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 $HOME/.aspnet/https:/https:ro \ -e CERTIFICATE_PATH=$HOME/.aspnet/https/ironsecuredoc.pfx \ -e CERTIFICATE_PASSWORD=<CERTIFICATE_PASSWORD> \ ironsoftwareofficial/ironsecuredoc:latestSHELL
<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_or_name>SHELL -
Start the container:
docker start <container_id_or_name>SHELL -
Remove the container:
docker rm -f <container_id_or_name>SHELL
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-1allows requests to run indefinitely.ALLOWED_ORIGINS: Configures Cross-Origin Resource Sharing (CORS) by specifying allowed origin URLs. Separate multiple URLs with commas. Use*orallto allow requests from any origin.HTTP_PORTS: Defines the HTTP ports the container exposes. This should match the port mapping using the-pflag (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 the-pflag (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
# Redact specific words in a PDF document
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'
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
# Redact text based on a regular expression in a PDF document
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'
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.
Frequently Asked Questions
How can I run IronSecureDoc on my Mac?
To run IronSecureDoc on a Mac, ensure Docker Desktop is installed and running. You can then pull the IronSecureDoc Docker image and run it with the necessary environment variables.
What are the prerequisites for hosting IronSecureDoc on a Mac?
Before hosting IronSecureDoc on a Mac, you should have Docker Desktop installed and running on your system, compatible with both Intel and Apple silicon Macs.
How do I access the IronSecureDoc container once it's running?
You can access the IronSecureDoc container by navigating to 'http://localhost:8080/swagger/index.html' in a web browser, where you will see the IronSecureDoc interface.
How do I run the IronSecureDoc container with a certificate?
To use a certificate, generate an HTTPS development certificate with 'dotnet dev-certs https'. Then, run the Docker container with the appropriate environment variables, including paths to the certificate and its password.
What environment variables can be configured in IronSecureDoc?
Configurable environment variables in IronSecureDoc include PDF_MAX_SIZE_MB, REQUEST_TIMEOUT_SECONDS, ALLOWED_ORIGINS, HTTP_PORTS, HTTPS_PORTS, and IronSecureDoc_LicenseKey.
How do I redact text in a PDF using IronSecureDoc?
You can redact text by sending a POST request to the IronSecureDoc API with the document and parameters for the text you'd like to redact using curl.
What is the purpose of the IronSecureDoc container?
The IronSecureDoc container provides offline document security and compliance through a powerful PDF manipulation REST API, reducing reliance on online SaaS services.
Can IronSecureDoc handle PDF redaction using regular expressions?
Yes, IronSecureDoc supports PDF text redaction using regular expressions through its REST API endpoints, enabling targeted content removal.
What should you do if the container needs to support HTTPS?
Generate an HTTPS certificate, trust it using 'dotnet dev-certs', and run the Docker container using environment variables to specify the certificate path and password.
Where can I find the full list of REST API endpoints for IronSecureDoc?
The complete list of REST API endpoints for IronSecureDoc can be found in the REST API Reference available in the documentation.

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.