已更新 2024年12月10日
分享:

如何拉取並運行 IronPdfEngine

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

從 Dockerhub、AWS ECR 公共庫或 AWS 市場中提取並運行 IronPdfEngine 映像,涉及提取預建容器映像,然後在 Docker 環境中執行它。

拉取:這是指從指定註冊處檢索IronPdfEngine容器映像(Dockerhub、AWS ECR Public Gallery 或 AWS Marketplace)到您的本地系統。 docker pull 命令通常用於此目的。

運行:一旦拉取了映像,您就可以使用 docker run 命令來基於該映像啟動容器實例。 這會在 Docker 容器內啟動 IronPdfEngine 應用程序,讓您可以利用其功能。

開始使用 IronPDF

立即在您的專案中使用IronPDF,並享受免費試用。

第一步:
green arrow pointer


在Dockerhub中獲取IronPdfEngine

先決條件

  • Docker 必須安裝。

設置

  1. 前往 https://hub.docker.com/r/ironsoftwareofficial/ironpdfengine

  2. 拉取 ironsoftwareofficial/ironpdfengine 映像
  docker pull ironsoftwareofficial/ironpdfengine

或拉取特定版本(推薦)

  docker pull ironsoftwareofficial/ironpdfengine:2023.12.6
  1. 運行 ironsoftwareofficial/ironpdfengine 容器。

    此命令將創建一個容器並在後台運行,使用端口 33350。

  docker run -d -p 33350:33350 ironsoftwareofficial/ironpdfengine

學習如何配置IronPdf客戶端以利用IronPdfEngine,請導航至"將代碼更新為使用IronPdfEngine.


IronPdfEngine 在 Docker compose 內

關鍵在於設置一個 Docker 網絡,使 IronPdfEngine 和您的應用程序可以相互看見。 將 'depends_on' 設定為確保 IronPdfEngine 啟動之前您的應用程式已經啟動。

設置

  1. 首先創建一個 docker-compose.yml 文件。使用以下模板設置您的 Docker Compose 文件:
version: "3.6"
services:
  myironpdfengine:
    container_name: ironpdfengine
    image: ironsoftwareofficial/ironpdfengine:latest
    ports:
      - "33350:33350"
    networks:
      - ironpdf-network
  myconsoleapp:
    container_name: myconsoleapp
    build:
      # enter YOUR project directory path here
      context: ./MyConsoleApp/
      # enter YOUR dockerfile name here, relative to project directory
      dockerfile: Dockerfile
    networks:
      - ironpdf-network
    depends_on:
      myironpdfengine:
        condition: service_started
networks:
  ironpdf-network: 
    driver: "bridge"
  1. 在您的應用程序中設置 IronPdfEngine 的地址(myconsoleapp)"myironpdfengine:33350"

  2. 執行 docker compose
docker compose up --detach --force-recreate --remove-orphans --timestamps

在 AWS ECR 公共圖庫中獲取 IronPdfEngine

先決條件

  • Docker 必須安裝。

設置

  1. 前往 https://gallery.ecr.aws/v1m9w8y1/ironpdfengine

  2. 拉取 v1m9w8y1/ironpdfengine 映像
docker pull https://gallery.ecr.aws/v1m9w8y1/ironpdfengine

或拉取特定版本(推薦)

docker pull https://gallery.ecr.aws/v1m9w8y1/ironpdfengine:2023.12.6
  1. 运行 ironpdfengine 容器。

    此命令將創建一個容器並在後台運行,端口為33350。

docker run -d -p 33350:33350 ironsoftwareofficial/ironpdfengine

學習如何配置IronPdf客戶端以利用IronPdfEngine,請導航至"將代碼更新為使用IronPdfEngine.


在 AWS Marketplace 獲取 IronPdfEngine

AWS Marketplace

先決條件

  • Docker 必須安裝。
  • AWS CLI 必須安裝並登入。

設置

  1. 前往IronPdfEngine 在 AWS 市場. 點擊「繼續訂閱」。

  2. 接受條款。

    接受最終用戶許可協議
  3. 繼續配置。

    訂閱完成
  4. 拉取 ironpdfengine 映像檔。 此步驟將向您展示拉取 ironpdfengine 映像的命令。
    啟動此軟體

    例如:

aws ecr get-login-password \
    --region us-east-1 
 docker login \
    --username AWS \
    --password-stdin 000000000000.dkr.ecr.us-east-1.amazonaws.com
CONTAINER_IMAGES="000000000000.dkr.ecr.us-east-1.amazonaws.com/iron-software/ironpdfengine:2024.1.15"    
for i in $(echo $CONTAINER_IMAGES 
 sed "s/,/ /g"); do docker pull $i; done
  1. 運行 ironpdfengine 容器。 此命令將創建一個容器並讓其在背景中運行,使用端口33350。
docker run -d -p 33350:33350 000000000000.dkr.ecr.us-east-1.amazonaws.com/iron-software/ironpdfengine:2024.1.15

在 Azure 市場獲取 IronPdfEngine

Azure 市場

設置

  1. 前往IronPDF Docker 容器在 Azure 市場上. 點擊“立即獲取”和“繼續”。

  2. 完成「基本資料」、「叢集詳情」和「應用程式詳情」以建立 Kubernetes 服務。

  3. 部署完成後,在左側的側邊欄中,前往 Kubernetes 資源 -> 執行命令。 運行以下命令:
kubectl get services
Kubernetes 服務 - 運行命令

使用 EXTERNAL-IP 和 PORT 的資訊(S),您可以相應地配置 IronPDFEngine 連接。

:path=/static-assets/pdf/content-code-examples/how-to/pull-run-ironpdfengine-azure-marketplace.cs
using IronPdf;
using IronPdf.GrpcLayer;

IronPdf.License.LicenseKey = "IRONPDF-MYLICENSE-KEY-1EF01";

IronPdfConnectionConfiguration configuration = new IronPdfConnectionConfiguration();
configuration.ConnectionType = IronPdfConnectionType.RemoteServer;
configuration.Host = "http://48.216.143.233";
configuration.Port = 80;
IronPdf.Installation.ConnectToIronPdfHost(configuration);

ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");
pdf.SaveAs("output.pdf");
Imports IronPdf
Imports IronPdf.GrpcLayer

IronPdf.License.LicenseKey = "IRONPDF-MYLICENSE-KEY-1EF01"

Dim configuration As New IronPdfConnectionConfiguration()
configuration.ConnectionType = IronPdfConnectionType.RemoteServer
configuration.Host = "http://48.216.143.233"
configuration.Port = 80
IronPdf.Installation.ConnectToIronPdfHost(configuration)

Dim renderer As New ChromePdfRenderer()
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>testing</h1>")
pdf.SaveAs("output.pdf")
VB   C#

將代碼更新為使用IronPdfEngine

這涉及修改代碼以確保 IronPdf 指向 IronPdfEngine 所公開的正確端口。這項操作對每種程式語言略有不同。 請參考以下文章以獲取具體使用說明:

-IronPDF for .NET

-IronPDF for Java

-IronPDF for Node.js

-IronPDF for Python

此外,您可以將此容器部署在任何地方。 不要忘記開放33350端口,並確保IronPdf客戶端可以訪問。 要了解更多關於IronPdfEngine及其限制的信息,請訪問"IronPdfEngine 是什麼?" 文章。

查克尼思·賓

查克尼思·賓

軟體工程師

Chaknith 致力於 IronXL 和 IronBarcode。他在 C# 和 .NET 方面擁有豐富的專業知識,協助改進軟體並支持客戶。他從用戶互動中獲得的洞察力有助於提高產品、文檔和整體體驗。