简体   繁体   中英

Adding an image to Pdf via Applet

I am trying to add an image to a pdf document via java applet. I am able to it successfully when i run the applet via applet viewer in eclipse IDE. But when i embedded this applet to a webpage, the pdf which is getting created is somehow corrupted. What am i doing wrong? I am using iText to do this.

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");

I signed the itext jar files, and got rid of the exception.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM