如何在 Google Cloud 中執行IronPDF 適用於 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>
<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>
<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 上不支持 Zip 部署 PDF 庫?
不支持 Zip 部署,因為 IronPDF 需要在運行時執行二進制文件,而這在標準 Zip 部署方法中是無法實現的。
在 Google Cloud 上部署 PDF 庫需要哪些附加依賴項?
可能需要的附加依賴項包括 perfmark-api、grpc-okhttp 和 grpc-netty-shaded。這些依賴項確保部署後庫能正常運行。
如何在 Google Cloud Docker 映像中處理 PDF 庫的包需求?
默認的 Cloud Function Docker 映像缺少 Chrome 所需的包。使用自定義 Dockerfile 安裝所有必需包,並按照 IronPDF Linux 部署指南中的指示進行操作。
是否有特定的 Maven 插件需要在 Docker 環境中部署 PDF 庫?
maven-shade-plugin 可能是 Docker 環境所需的,它應該配置為使用轉換器,特別是在處理複雜的依賴關係時。
如何在 Docker 環境中設置 PDF 引擎的工作目錄?
您可以使用 Setting.setIronPDFEngineWorkingDirectory(Paths.get("/tmp/")) 設置 PDF 引擎的工作目錄。確保使用如 RUN chmod 777 /tmp/ 的命令在您的 Dockerfile 中授予必要的權限。

