java - Creating a 3D shadow effect on images with itextpdf -


i want create 3d shadow effect on images place in pdf. using itextpdf. question similar : adding shadow effect on itext elements

but images , not texts. images placed in table cells. long table not completed, no way actual size of image nor coordinates in page, makes tricky. brilliant id ? , regards, sylvain

4 hours later, found way using pdfcellevent , drawing need inside cell's padding.

static class shadowrectangle implements pdfpcellevent {         public void celllayout(pdfpcell cell, rectangle rect,                                pdfcontentbyte[] canvas) {             pdfcontentbyte lcb = canvas[pdfptable.linecanvas];              // paddings border         int paddinghorizontal = 8;         int paddingvertical = 8;          // width of shadow         int shadowwidth = 7;          // calculate border location , size         float left = rect.getleft() + paddinghorizontal;         float bottom = rect.getbottom() + paddingvertical;         float width = rect.getwidth() - 2 * paddinghorizontal;         float height = rect.getheight() - 2 * paddingvertical;           lcb.savestate();         lcb.setcolorfill(basecolor.gray);         // draw shadow @ bottom         lcb.rectangle(left + shadowwidth, bottom - shadowwidth, width, shadowwidth);         lcb.fill();         // draw shadow @ right         lcb.rectangle(left + width, bottom - shadowwidth, shadowwidth, height);         lcb.fill();          //lcb.setcolorstroke(basecolor.red);         // draw border         //lcb.rectangle(left, bottom, width, height);          lcb.stroke();         lcb.restorestate();     } } 

// , fill pdfptable way

pdfptable limages = new pdfptable(nb_picture_per_row); limages.getdefaultcell().setborder(rectangle.no_border); 

// ... in loop

limageboucle = image.getinstance(lfile.getcanonicalpath() + file.separator + ltabphotos[i]);                 pdfpcell lcell = new  pdfpcell();                 lcell.setimage(limageboucle);                 lcell.setborder(rectangle.no_border);                 lcell.setpadding(8);                  pdfpcellevent lshadowrectangle = new shadowrectangle();                 lcell.setcellevent(lshadowrectangle);                 limages.addcell(lcell); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -