我正在尝试使用视觉签名和pdfbox制作PDF.我有两个流,似乎pdfbox只能处理文件.没有三个临时文件,我没有设法让它工作.我可以从这里看到API已经改变,但它仍处理文件.
public void signPdf(InputStream originalPdf, OutputStream signedPdf,
InputStream image, float x, float y,
String name, String location, String reason) {
File temp = null;
File temp2 = null;
File scratchFile = null;
RandomAccessFile randomAccessFile = null;
OutputStream tempOut = null;
InputStream tempIn = null;
try {
/* Copy original to temporary file */
temp = File.createTempFile("signed1", ".tmp");
tempOut = new FileOutputStream(temp);
copyStream(originalPdf, tempOut);
tempOut.close();
/* Read temporary file to second temporary file and stream */
tempIn = new …
Run Code Online (Sandbox Code Playgroud) 今天我们可以看到,可以通过提供图像作为输入来创建新的 PDVisibleSignDesigner 对象,该对象稍后将显示在 PDF 文档中。
new PDVisibleSignDesigner(String filename, InputStream imageStream, int page)
Run Code Online (Sandbox Code Playgroud)
如果通过了绿色复选标记图像(参考:imageStream 参数),则当您的签名有效时,这完全有意义。但今天,即使您的签名无效,它也会显示相同的图像。但从逻辑上讲,人们希望显示不同的图像,例如一些红十字标记。
我们如何使用 pdfbox api 来完成它(我使用的是 2.0.8 版本)?