如何在 Google Cloud 中運行 IronPDF for Java
Note: We have not fully tested support with Google Cloud, but if you want to try, we have some Required Settings.
重要提示:必需設置
- 由於 IronPDF 需要在執行時間執行二進位文件,因此不支援 Zip 部署。
預設的雲端函數 Docker 映像無法正常運作,因為它們缺少 Chrome 正常運作所需的軟體包。 有關更多信息,請參閱Google Cloud 系統包。 請使用自訂 Dockerfile 並安裝所有必要的軟體包。 請參閱我們的Linux 部署指南,以了解更多資訊。
將
ironpdf-engine-linux-x64依賴項新增至您的專案(將版本編號變更為最新版本):<dependency> <groupId>com.ironsoftware</groupId> <artifactId>ironpdf-engine-linux-x64</artifactId> <version>2022.xx.x</version> </dependency><dependency> <groupId>com.ironsoftware</groupId> <artifactId>ironpdf-engine-linux-x64</artifactId> <version>2022.xx.x</version> </dependency>XML
*可能需要此插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<!-- required for Docker -->
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
</plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<!-- required for Docker -->
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
</plugin>*可能需要以下相依性:
<dependency>
<groupId>io.perfmark</groupId>
<artifactId>perfmark-api</artifactId>
<version>0.26.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-okhttp</artifactId>
<version>1.50.2</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<version>1.50.2</version>
</dependency> <dependency>
<groupId>io.perfmark</groupId>
<artifactId>perfmark-api</artifactId>
<version>0.26.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-okhttp</artifactId>
<version>1.50.2</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<version>1.50.2</version>
</dependency>- 由於啟動緩慢,請將
timeout設定為330 seconds。 - 將
memory size設定為至少2048 MB。 - 將
Ephemeral Storage Size設定為至少1024 MB。 在某些環境下,您可能需要指定
IronPdfEngineWorkingDirectory並為其設定執行權限:// Set the working directory for the IronPDF Engine Setting.setIronPdfEngineWorkingDirectory(Paths.get("/tmp/"));// Set the working directory for the IronPDF Engine Setting.setIronPdfEngineWorkingDirectory(Paths.get("/tmp/"));JAVA# Grant full read/write/execute permissions to the /tmp directory RUN chmod 777 /tmp/
常見問題解答
如何在 Google Cloud 上設定 Java 的 PDF 函式庫?
若要在 Google Cloud 上架設 PDF 函式庫,請使用自訂的 Dockerfile 來安裝所有必要的套件,詳情請參閱 IronPDF Linux 部署指南。包含 ironpdf-engine-linux-x64 相依性,並配置特定設定以獲得最佳效能。
在 Google Cloud 上執行 PDF 函式庫需要哪些特定設定?
在 Google Cloud 上執行 PDF 函式庫時,請使用 330 秒的逾時時間、至少 2048 MB 的記憶體大小,以及至少 1024 MB 的短暫儲存大小。此外,請設定 IronPdfEngineWorkingDirectory 並確保該目錄的執行權限。
為什麼 Google Cloud 上的 PDF 函式庫不支援 Zip 部署?
不支援 Zip 部署,因為 IronPDF 需要在執行時執行二進位檔案,而標準的 Zip 部署方法並不可行。
在 Google Cloud 上部署 PDF 函式庫需要哪些額外的依賴項目?
可能需要的其他相依性包括 perfmark-api, grpc-okhttp, 和 grpc-netty-shaded.這些元件可確保資料庫在部署時能正常運作。
如何處理 Google Cloud Docker 影像中 PDF 函式庫的套件需求?
預設的 Cloud Function Docker 映像檔缺乏 Chrome 所需的套件。請按照 IronPdf.Linux 部署指南中的指示,使用自訂的 Dockerfile 安裝所有必要的套件。
在 Docker 環境中部署 PDF 函式庫是否需要特定的 Maven 外掛程式?
Docker 環境可能需要maven-shade-plugin。應將其設定為使用轉換器,尤其是在處理複雜的相依性時。
如何在 Docker 環境中設定 PDF 引擎的工作目錄?
您可以使用 Setting.setIronPdfEngineWorkingDirectory(Paths.get("/tmp/")) 設定 PDF 引擎的工作目錄。確保您在 Dockerfile 中使用 RUN chmod 777 /tmp/ 之類的指令授予必要的權限。







