[英]Adding an image to Pdf via Applet
I am trying to add an image to a pdf document via java applet. 我正在尝试通过java applet将图像添加到pdf文档中。 I am able to it successfully when i run the applet via applet viewer in eclipse IDE. 当我通过Eclipse IDE中的applet Viewer运行applet时,我能够成功完成此操作。 But when i embedded this applet to a webpage, the pdf which is getting created is somehow corrupted. 但是,当我将此小程序嵌入到网页中时,正在创建的pdf某种程度上已损坏。 What am i doing wrong? 我究竟做错了什么? I am using iText to do this. 我正在使用iText执行此操作。
Here is the code i use: 这是我使用的代码:
Document document=new Document();
PdfWriter.getInstance(document, new FileOutputStream("C://Folder/abc.pdf"));
document.open();
Image img=Image.getInstance("C://New/abcd.png");
img.scaleToFit(400,400);
document.add(img);
document.close();
Any help will be greatly appreciated. 任何帮助将不胜感激。 Thank you. 谢谢。
I solved the problem. 我解决了问题。 the applet was throwing access control exception on line Image img=Image.getInstance("C://New/abcd.png"); 小程序在行Image img = Image.getInstance(“ C://New/abcd.png”)上引发访问控制异常;
I signed the itext jar files, and got rid of the exception. 我签名了itext jar文件,并摆脱了异常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.