在 Java 中将 JPG转换为PDF

用于将JPG转换为PDF的高速软件Java

使用我们的文档转换 API 在 Java 中创建可移植、健壮和安全的软件。这是一个完整的专业软件解决方案,可Java JPG, PDF和许多其他文档格式。

查看代码片段

在 Java 中将 JPG 转换为 PDF

需要以编程方式将 JPG 图像转换为 PDF 文件?借助Aspose.Words for Java,任何开发人员只需几行 Java 代码即可轻松将 JPG 转换为 PDF 格式。

现代图像处理 Java API 从 JPG 图像高速创建 PDF。直接在浏览器中测试 JPG 到 PDF 转换的质量。强大的 Java 库允许将 JPG 图片转换为许多流行的文档格式。

在 Java 中将 JPG 保存为 PDF

以下示例演示了如何在 Java 中将 JPG 转换为 PDF。

按照简单的步骤将 JPG 图像转换为 PDF 格式。从本地驱动器读取 JPG 图像,然后将其简单保存为 PDF,通过 PDF 扩展名指定所需的文档格式。对于 JPG 读取和 PDF 写入,您可以使用完全限定的文件名。输出的 PDF 内容将与原始 JPG 图像相同。

Java代码示例将JPG转换为PDF格式
上传您要转换的文件
运行代码
从列表中选择目标格式
import com.aspose.words.*;

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.insertImage("Input.jpg");

doc.save("Output.pdf");
import com.aspose.words.*; Document doc = new Document("Input.jpg"); doc.save("Output.pdf"); import com.aspose.words.*; Document doc = new Document("Input.jpg"); for (int page = 0; page < doc.getPageCount(); page++) { Document extractedPage = doc.extractPages(page, 1); extractedPage.save(String.format("Output_%d.pdf", page + 1)); } import com.aspose.words.*; Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.insertImage("Input.jpg"); doc.save("Output.pdf"); import com.aspose.words.*; Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); Shape shape = builder.insertImage("Input.jpg"); shape.getShapeRenderer().save("Output.pdf", new ImageSaveOptions(SaveFormat.pdf));
运行代码
在社交媒体上分享代码:

如何将JPG转换为PDF

  1. Aspose.Words for Java安装 Aspose.Words。
  2. 将库引用(导入库)添加到您的Java项目。.
  3. 在Java打开源JPG文件。.
  4. 调用save()方法,传递带有PDF扩展名的输出文件名。.
  5. JPG转换的结果PDF 。.

Java库将JPG转换为PDF

我们在Maven存储库中托管我们的 Java 'Aspose.Words for Java' 是一个常见的包含字节码的 JAR 请按照有关如何将其安装到 Java 开发人员环境的分步说明进行操作。

系统要求

Java SE 7 和更新的 Java 版本。 Java SE 6 提供了一个单独的包,以防您不得不使用这个过时的 JRE 。

我们的 Java 包是跨平台的,可以在所有具有 JVM 实现的 Microsoft Windows 、Linux、macOS、Android 和 iOS。

有关可选包依赖项的信息,例如 JogAmp JOGL 、 Harfbuzz 字体引擎、 Java Advanced Imaging JAI ,请参阅产品文档

5%

订阅 Aspose 产品更新

获取直接发送到您的邮箱的每月通讯和优惠。

© Aspose Pty Ltd 2001-2024. 版权所有。