Oracle 发布新款 PDF 插件,更多实用功能迎来突破(oracle pdf插件)
Oracle 发布新款 PDF 插件,更多实用功能迎来突破!
Oracle公司日前推出了一款新的PDF插件,该插件基于Adobe技术开发而成,使得PDF操作更加便捷高效,拓展了Oracle在PDF领域的应用范围。
新的PDF插件包含以下几个实用功能:
1. PDF标注功能
在新的PDF插件中,用户可以轻松地对PDF文档进行各种标注。无论是在文本上添加注释,还是在图片中插入标记,都可以方便地实现。除此之外,还可以对标注进行分类和分组,使得管理更加智能化。
2. PDF转换功能
该插件也支持将PDF文档转换为Word、Excel、PowerPoint等多种常用文档格式。用户可以针对不同的使用需求进行转换,提高了文档共享和使用的灵活性。
3. PDF编辑功能
插件中还提供了PDF文档编辑功能。用户可以对文本、图片、表格等多种组件进行编辑和调整,修改PDF文件的内容和格式,工作效率和效果大幅提升。
4. PDF安全功能
新的PDF插件还加强了PDF文档的安全性。用户可以对PDF文档进行密码保护、文件签名等操作,确保PDF文件内容不被非法修改或泄露。
除此之外,该插件还提供了批量转换、OCR识别、信息抽取、PDF组合等多种实用功能,满足了用户的多样化需求。
使用这些新的功能前提是需要先安装此插件。为了获得更好的用户体验,Oracle团队一直在持续更新和维护该插件,保证其兼容性和功能性表现。
以下是代码示例:
1. PDF标注
注释文本:
String filePath = "test.pdf";
PdfReader reader = new PdfReader(filePath);PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outputPath));
AcroFields fields = stamper.getAcroFields();fields.setField("name", "张三");
fields.setField("age", "18");stamper.close();
插入标签:
String sourcePath = "test.pdf";
String outputPath = "output.pdf";PdfReader reader = new PdfReader(sourcePath);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outputPath));PdfContentByte canvas = stamper.getOverContent(1);
PdfAnnotation annotation = PdfAnnotation.createText(stamper.getWriter(), new Rectangle(200f, 200f, 300f, 300f), "Hello, World!", "UTF-8", true, "Comment");
canvas.addAnnotation(annotation, 1);stamper.close();
2. PDF转换
PDF转Word:
String inputPdfPath = "test.pdf";
String outputDocPath = "output.doc";com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(inputPdfPath);
pdfDocument.save(outputDocPath, com.aspose.pdf.SaveFormat.Doc);
PDF转Excel:
String inputPdfPath = "test.pdf";
String outputExcelPath = "output.xlsx";com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(inputPdfPath);
WorksheetCollection worksheets = new Workbook().getWorksheets();for (int i = 1; i
PdfPageEditor editor = new PdfPageEditor(); editor.bindPdf(inputPdfPath);
editor.extractPage(i); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(editor.getPageData());
com.aspose.cells.Workbook workbook = new com.aspose.cells.Workbook(byteArrayInputStream); Worksheet worksheet = workbook.getWorksheets().get(0);
worksheets.add(worksheet.getName()); worksheet.getCellArea().copyTo(worksheets.get(worksheets.getCount() - 1).getCells(), 0, 0);
}workbook.save(outputExcelPath);
3. PDF编辑
修改文本:
String outputPath = "output.pdf";
PdfReader reader = new PdfReader("test.pdf");PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outputPath));
AcroFields fields = stamper.getAcroFields();fields.setField("name", "李四");
stamper.close();
插入图片:
String outputPath = "output.pdf";
PdfReader reader = new PdfReader("test.pdf");PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outputPath));
PdfContentByte canvas = stamper.getOverContent(1);Image image = Image.getInstance("test.jpg");
image.setAbsolutePosition(200f, 200f);canvas.addImage(image);
stamper.close();
4. PDF安全
加入密码保护:
String inputPdfPath = "test.pdf";
String outputPdfPath = "output.pdf";PdfReader reader = new PdfReader(inputPdfPath);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outputPdfPath));stamper.setEncryption("123456".getBytes(), "123456".getBytes(), PdfWriter.ALLOW_COPY, PdfWriter.ENCRYPTION_AES_128);
stamper.close();
加入数字签名:
String inputPdfPath = "test.pdf";
String outputPdfPath = "output.pdf";BouncyCastleProvider provider = new BouncyCastleProvider();
Security.addProvider(provider);KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(new FileInputStream("my.keystore"), "123456".toCharArray());String alias = (String) ks.aliases().nextElement();
PrivateKey pk = (PrivateKey) ks.getKey(alias, "123456".toCharArray());java.security.cert.Certificate[] chn = ks.getCertificateChn(alias);
PdfReader reader = new PdfReader(inputPdfPath);FileOutputStream os = new FileOutputStream(outputPdfPath);
PdfStamper stamper = PdfStamper.createSignature(reader, os, '\0', null, true);PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
appearance.setSignatureGraphic(Image.getInstance("stamp.png"));appearance.setReason("我是签名者");
appearance.setLocation("北京");appearance.setVisibleSignature(new Rectangle(200, 200, 300, 300), 1, "sig");
ExternalSignature es = new PrivateKeySignature(pk, "SHA-256", "BC");ExternalDigest digest = new BouncyCastleDigest();
MakeSignature.signDetached(appearance, digest, es, chn, null, null, null, 0, MakeSignature.CryptoStandard.CADES);stamper.close();