没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|使用教程|编辑:李显亮|2021-03-17 10:35:07.930|阅读 354 次
概述:图像被广泛用于PDF文件中的不同类型的描绘和演示。在本文中,将学习如何以编程方式处理PDF文件中的图像。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
相关链接:
图像被广泛用于PDF文件中的不同类型的描绘和演示。在本文中,将学习如何以编程方式处理PDF文件中的图像。特别是,本文将介绍如何使用Java添加,提取,删除或替换PDF文件中的图像。
Aspose.PDF for Java是功能强大的API,可为您提供多种PDF操作功能。该API可让您无缝处理PDF文件中的文本,注释或图像。感兴趣的朋友可点击下方按钮下载最新版。
以下是使用Java在PDF文件中添加图像的步骤。
以下代码示例显示了如何使用Java将图像添加到PDF文件。
// Open a document
Document pdfDocument1 = new Document("input.pdf");
// Set coordinates
int lowerLeftX = 100;
int lowerLeftY = 100;
int upperRightX = 200;
int upperRightY = 200;
// Get the page you want to add the image to
Page page = pdfDocument1.getPages().get_Item(1);
// Load image into stream
java.io.FileInputStream imageStream = new java.io.FileInputStream(new java.io.File("input_image1.jpg"));
// Add an image to the Images collection of the page resources
page.getResources().getImages().add(imageStream);
// Using the GSave operator: this operator saves current graphics state
page.getContents().add(new Operator.GSave());
// Create Rectangle and Matrix objects
Rectangle rectangle = new Rectangle(lowerLeftX, lowerLeftY, upperRightX, upperRightY);
Matrix matrix = new Matrix(new double[] { rectangle.getURX() - rectangle.getLLX(), 0, 0, rectangle.getURY() - rectangle.getLLY(), rectangle.getLLX(), rectangle.getLLY() });
// Using ConcatenateMatrix (concatenate matrix) operator: defines how image must be placed
page.getContents().add(new Operator.ConcatenateMatrix(matrix));
XImage ximage = page.getResources().getImages().get_Item(page.getResources().getImages().size());
// Using Do operator: this operator draws image
page.getContents().add(new Operator.Do(ximage.getName()));
// Using GRestore operator: this operator restores graphics state
page.getContents().add(new Operator.GRestore());
// Save the new PDF
pdfDocument1.save("Updated_document.pdf");
// Close image stream
imageStream.close();
以下是使用Java从PDF文档提取图像的步骤。
以下代码示例显示了如何使用Java从PDF文件提取图像。
// Open a document
Document pdfDocument = new Document("input.pdf");
// Extract a particular image
XImage xImage = pdfDocument.getPages().get_Item(1).getResources().getImages().get_Item(1);
// Create stream object to save the output image
java.io.OutputStream output = new java.io.FileOutputStream("output.jpg");
// Save the output image
xImage.save(output);
// Close stream
output.close();
以下是使用Java从PDF文件中删除图像的步骤。
以下代码示例显示了如何使用Java删除PDF中的图像。
// Open a document
Document pdfDocument = new Document("input.pdf");
// Delete a particular image
pdfDocument.getPages().get_Item(1).getResources().getImages().delete(1);
// Save the updated PDF file
pdfDocument.save("output.pdf");
以下是使用Java替换PDF文件中的图像的步骤。
以下代码示例显示了如何使用Java替换PDF中的图像。
// Open a document
Document pdfDocument = new Document("input.pdf");
// Replace a particular image
pdfDocument.getPages().get_Item(1).getResources().getImages().replace(1, new java.io.FileInputStream(new java.io.File("apose.png")));
// Save the updated PDF file
pdfDocument.save("output.pdf");
如果你想试用Aspose的全部完整功能,可联系在线客服获取30天临时授权体验。
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@ke049m.cn




注意: Cogent DataHub 软件 v11 包含一些新功能,您的目标操作系统可能不支持这些功能。
本教程主要为大家介绍如何使用DevExpress WinForms数据网格控件进行数据排序的基础知识,欢迎下载最新版组件体验!
在使用Parasoft C/C++test执行BugDetective数据流分析时,可能会遇到用户自定义的资源API,那在这种情况下,若要判断是否存在资源问题,如资源泄露等,则需要手动配置测试配置。
大型SaaS系统的自动化测试常常受制于界面变化快、结构复杂、加载机制多变等因素。从元素识别到脚本管理,SmartBear TestComplete帮助Salesforce建了可靠的自动化测试体系。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@ke049m.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
半岛外围网上直营