如何在Java中合并PDF

为小型企业和大型企业,保持 您的 重要 文件, 组织将提高您的工作流程,并成倍增长你的组织的工作效率。 PDF文档由于其接受的输入格式的类型的安全性和灵活性,通常是共享大量信息的理想格式 。

但是,当需要同时共享多个PDF文档时,将相似的文档合并到一个文件中可能会更有用。 例如,如果您共享或收集订单, ç Ø ñ牛逼[R一ç牛逼小号, 发票或报表,存储都喜欢在一个文件中的文件,将大大提高您的 工作效率和组织,特别是如果 表格必须进行排序一种具体的方式。 这将节省您和接收者 的 时间和麻烦 ,这可能是由于丢失单独的文档轨道或如果文档的读取顺序不正确而造成的 。

随着 2 以下 转换API小号,我们会告诉你如何合并两个或多个PDF文档合并成一个文件到您整理的帮助,并分享您的文档更容易。 我们此过程的主要目标是保持格式并在合并后保留文档的顺序。

此处显示的第一个API 将合并Java中的两个PDF文档。 我们第一步应该为t Ø安装 我们的图书馆 与 我们的仓库参考 Maven的 POM文件。

jitpack.io

https://jitpack.io

然后,您可以 在pom.xml中添加对依赖项的引用:

com.github.Cloudmersive

Cloudmersive.APIClient.Java

v3.54

与Gradle安装,添加 这个 在你的根 的build.gradle 在库的结尾:

allprojects {

repositories {

...

maven { url 'https://jitpack.io' }

}

}

并且, 在build.gradle中添加依赖 项:

dependencies {

implementation 'com.github.Cloudmersive:Cloudmersive.APIClient.Java:v3.54'

}

然后,在我们的函数中,将导入添加到文件顶部:

// Import classes:

//import com.cloudmersive.client.invoker.ApiClient;

//import com.cloudmersive.client.invoker.ApiException;

//import com.cloudmersive.client.invoker.Configuration;

//import com.cloudmersive.client.invoker.auth.*;

//import com.cloudmersive.client.MergeDocumentApi;

Ø NCE我们已经完成了这一步,我们可以调用我们的功能, 中号ergeDocumentPdf :

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure API key authorization: Apikey

ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");

Apikey.setApiKey("YOUR API KEY");

// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)

//Apikey.setApiKeyPrefix("Token");

MergeDocumentApi apiInstance = new MergeDocumentApi();

File inputFile1 = new File("/path/to/inputfile"); // File | First input file to perform the operation on.

File inputFile2 = new File("/path/to/inputfile"); // File | Second input file to perform the operation on (more than 2 can be supplied).

try {

byte[] result = apiInstance.mergeDocumentPdf(inputFile1, inputFile2);

System.out.println(result);

} catch (ApiException e) {

System.err.println("Exception when calling MergeDocumentApi#mergeDocumentPdf");

e.printStackTrace();

}

为了确保此API和我们的下一个API正常运行,我们需要确保以下几点:

确保输入文件有效

设置您的API密钥;可以从Cloudmersive网站上免费获得,并且可以通过我们的API库最多访问800个调用

如果您需要合并两个以上的文件,可以使用以下 功能插入最多十个输入文件的列表, 以 将其合并为一个PDF 。 使用此功能时,请注意,输入文件的放置顺序将保留在合并 文档中。 如果需要,您也可以执行这个动作 不止一次,并使用你的输出文件从第一个实例作为 第一个 为SE输入COND ,其次是要合并的文件的剩余部分。

要运行我们的第二个API,您应该首先执行与上述相同的安装步骤。然后,我们将再次将导入文件放在文件顶部,并调用我们的函数 M ergeDocumentPdfMulti :

// Import classes:

//import com.cloudmersive.client.invoker.ApiClient;

//import com.cloudmersive.client.invoker.ApiException;

//import com.cloudmersive.client.invoker.Configuration;

//import com.cloudmersive.client.invoker.auth.*;

//import com.cloudmersive.client.MergeDocumentApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure API key authorization: Apikey

ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");

Apikey.setApiKey("YOUR API KEY");

// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)

//Apikey.setApiKeyPrefix("Token");

MergeDocumentApi apiInstance = new MergeDocumentApi();

File inputFile1 = new File("/path/to/inputfile"); // File | First input file to perform the operation on.

File inputFile2 = new File("/path/to/inputfile"); // File | Second input file to perform the operation on.

File inputFile3 = new File("/path/to/inputfile"); // File | Third input file to perform the operation on.

File inputFile4 = new File("/path/to/inputfile"); // File | Fourth input file to perform the operation on.

File inputFile5 = new File("/path/to/inputfile"); // File | Fifth input file to perform the operation on.

File inputFile6 = new File("/path/to/inputfile"); // File | Sixth input file to perform the operation on.

File inputFile7 = new File("/path/to/inputfile"); // File | Seventh input file to perform the operation on.

File inputFile8 = new File("/path/to/inputfile"); // File | Eighth input file to perform the operation on.

File inputFile9 = new File("/path/to/inputfile"); // File | Ninth input file to perform the operation on.

File inputFile10 = new File("/path/to/inputfile"); // File | Tenth input file to perform the operation on.

try {

byte[] result = apiInstance.mergeDocumentPdfMulti(inputFile1, inputFile2, inputFile3, inputFile4, inputFile5, inputFile6, inputFile7, inputFile8, inputFile9, inputFile10);

System.out.println(result);

} catch (ApiException e) {

System.err.println("Exception when calling MergeDocumentApi#mergeDocumentPdfMulti");

e.printStackTrace();

}

原文链接:http://codingdict.com

java 合并pdf,如何在Java中合并PDF相关推荐

  1. java发送gmail_如何在Gmail中轻松通过电子邮件发送人群

    java发送gmail Mailing lists are an old tool in the email arsenal, but their implementation in Gmail is ...

  2. cmd中加载java源文件_如何在cmd中编译和运行java源文件

    如何在cmd中编译和运行java源文件 首先写一个名为HelloWorld.java的java源文件,存储在如C:/java/src的地址,我们再假设待会要存储的位置是C:/java/bin,则我们做 ...

  3. java 联合_如何在java中进行联合,相交,区分和反向数据

    我想在Java中有联合,相交,差异和反向操作. 首先我有2个ArrayList< Integer> a = [0,2,4,5,6,8,10] b = [5,6,7,8,9,10] 一个工会 ...

  4. java 运费_如何在Java中创建运费成本计算器

    我正在创建计算器来计算运费.代码是这样的:如何在Java中创建运费成本计算器 class ShippingCalc { public static void main(String[] args) { ...

  5. java 关闭jpanel_如何在Java中关闭Jpanel程序

    我正在制作一个Java游戏,我需要一些关于如何操作的建议.如何在Java中关闭Jpanel程序 目前我使用2个不同的.java文件来制作游戏.我有一个扩展JFrame的主程序,我调用扩展JPanel的 ...

  6. java 二叉查找树_如何在Java中实现二叉搜索树( binary search tree)?

    二叉搜索树或BST是一种流行的数据结构,用于保持元素的顺序.二叉搜索树是二叉树,其中左子节点的值小于或等于父节点,右子节点的值大于或等于父节点.由于它是二叉树,它只能有0,1或2个子节点.二叉搜索树之 ...

  7. java spring scope_如何在Spring中自定义scope的方法示例

    大家对于 Spring 的 scope 应该都不会默认.所谓 scope,字面理解就是"作用域"."范围",如果一个 bean 的 scope 配置为 sing ...

  8. amd cpu不能在cmd环境下运行java代码_如何在Windows10中配置java的JDK环境

    今天给大家分享一下如何配置java的JDK环境.操作步骤如下: 1.下载好 jdk 的安装文件,我下载的是 jdk-10.0.1_windows-x64_bin.exe 这个版本的安装文件: 2.使用 ...

  9. append 后如何删除_如何在STATA中合并数据文件呢?

    ❝ 作者:江小白 邮箱:jieresearch@163.com ❞ 我们在使用stata进行数据分析时,可能涉及多个数据文档的合并操作或者同时使用不同数据集中的多个变量,这都需要我们进行文档间不同变量 ...

最新文章

  1. 云栖专辑|阿里开发者们的第二个感悟:PG大V德哥的使命感与开放心态
  2. python怎么安装turtle_Python3.6安装turtle模块
  3. 《港诡实录》:搞恐怖和看大腿究竟哪个更重要?
  4. Unity 安卓连调profile失败
  5. 【Verilog HDL】从逻辑电路图到门级建模——人工翻译的方法论
  6. int *p = *******a是什么鬼?
  7. 联想+android电视,联想Android4.0智能电视亮相:4月底国内上市
  8. java代码传中文参数乱码
  9. 微信打飞机思路总结 蓝懿教育
  10. 易鲸捷数据库创建全局递增序列和oracle的RAC模式下的全局递增序列类似
  11. 金牛判势 精品起涨预警 主升浪起爆点指标 通达信绝对精准买点指标选股公式
  12. 功能强大的全新虚拟商品自动发货商城源码
  13. badboy 录制脚本,提示:“当前页面的脚本发生错误”
  14. 天牛须和贪心算法_天牛须算法
  15. 2020 工业互联领域最具商业合作价值企业盘点
  16. php谷歌地图,php – 使用谷歌地图提交位置
  17. 中国科技大学网络视频课程软件设计模式(自主模式)
  18. python运行报错: Permission denied: ‘xxx.xxx‘
  19. VideoCapX Video Crack,保存和访问这些视频和图像的需求
  20. 西安IT男的前景: 我是IT程序员,没有成堆的快递箱, 却有你们看不到的追逐自我

热门文章

  1. jquery通过name,id名称获取当前value值
  2. 无人驾驶技术的突破与挑战
  3. 什么是Nginx?有什么用?
  4. mysql 超卖_mysql 解决超卖问题的锁分析
  5. 如何理解卷积:信号处理、图像处理中的应用
  6. 雨林木风 Ghost XP SP3 纯净版 Y1.0
  7. 腾讯(大连)研发一面-20190620
  8. 集成学习算法的思想、通过集成学习提高整体泛化能力的前提条件、如何得到独立的分类器Bagging、Boosting、Stacking算法
  9. 安装RedHat Linux 7.4
  10. android notify() notifyAll()的区别