如何在 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.
重要:必要设置
- 不支持 Zip 部署,因为 IronPDF 需要在运行时执行二进制文件。
- 默认的云功能 Docker 映像无法工作,因为它们缺少 Chrome 浏览器正常运行所需的软件包。 有关详细信息,请参阅 Google 云系统软件包。
请使用自定义的 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>XML这些依赖项可能是必需的:
<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>XML- 由于启动缓慢,将
timeout设置为330 秒。 - 将
内存大小至少设置为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 所需的软件包。使用自定义 Dockerfile 按照 IronPDF Linux 部署指南安装所有必要的软件包。
在 Docker 环境中部署 PDF 库是否需要特定的 Maven 插件?
maven-shade-plugin 可能是 Docker 环境所需。它应该被配置以使用转换器,特别是在处理复杂依赖项时。
如何在 Docker 环境中设置 PDF 引擎的工作目录?
您可以使用 Setting.setIronPdfEngineWorkingDirectory(Paths.get("/tmp/")) 设置 PDF 引擎的工作目录。确保使用类似于 RUN chmod 777 /tmp/ 的命令在 Dockerfile 中授予必要的权限。







