iText -- how to associate actions with graphical object? -


i haven't been able find solution itext problem either here in itext in action book, , appreciate suggestions. want include technical diagrams, composed of rectangles, lines, etc. in pdf such diagram can float image would, such can associate pdf actions graphics objects such rectangles. need extend itext this?

for now, drawing graphics wmf package , inserting wmf image, cannot associate actions way or put graphical objects in layers.

please take @ addlinkimages example. @ first, planned use wmf files (as per request), didn't find many, used png, bmps , single wmp.

you want these images added other object, want add action them. can achieved wrap image inside chunk described in chapter 2 of book. once have chunk, can define pdfaction triggered when chunk (or in case, image wrapped in chunk) clicked:

public chunk createimage(string src, string url) throws badelementexception, ioexception {     image img = image.getinstance(src);     chunk chunk = new chunk(img, 0, 0, true);     chunk.setaction(new pdfaction(url));     return chunk; } 

note set changeleading parameter true. if don't that, leading of paragraph leading of text , images bigger, result in overlapping text , images. setting changeleading true, leading adapt height of images.

public void createpdf(string dest) throws ioexception, documentexception {     document document = new document();     pdfwriter writer = pdfwriter.getinstance(document, new fileoutputstream(dest));     document.open();     pdfcontentbyte cb = writer.getdirectcontent();     document.add(new paragraph("objects links"));     paragraph p = new paragraph();     p.add(createimage("resources/images/info.png", "http://itextpdf.com/"));     p.add(createimage("resources/images/dog.bmp", "http://pages.itextpdf.com/ebook-stackoverflow-questions.html"));     p.add(createimage("resources/images/fox.bmp", "http://stackoverflow.com/q/29388313/1622493"));     p.add(createimage("resources/images/butterfly.wmf", "http://stackoverflow.com/questions/tagged/itext*"));     document.add(p);     document.close(); } 

enter image description here


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -