iText - roundRectangle with no border -


is possible have roundrectangle no border? following code creates roundrectangles , rectangles border sizes of 0f , 1f. roundrectangle there still visible border when linewidth set 0f, not true rectangle border of 0f.

here code i'm using:

    magazine = new document(pagesize.letter,0,0,0,0);     pdfw = pdfwriter.getinstance(magazine, new fileoutputstream("out.pdf"));     magazine.open();      canvas = pdfw.getdirectcontent();      canvas.rectangle(0,0,600,750);     canvas.setcolorfill(basecolor.orange);     canvas.fillstroke();      canvas.setcolorstroke(basecolor.black);     canvas.setcolorfill(basecolor.gray);     canvas.setlinewidth(1f);      llx = 100;     lly = 100;     wid = 100;     hei = 100;     canvas.roundrectangle(llx,lly, wid, hei, 10);     canvas.fillstroke();      llx = 100;     lly = 210;     wid = 100;     hei = 100;     canvas.rectangle(llx,lly, wid, hei);     canvas.fillstroke();      canvas.setcolorstroke(basecolor.black);     canvas.setcolorfill(basecolor.white);     canvas.setlinewidth(0f);      llx = 210;     lly = 100;     wid = 100;     hei = 100;     canvas.roundrectangle(llx,lly, wid, hei, 10);     canvas.fillstroke();      llx = 210;     lly = 210;     wid = 100;     hei = 100;     canvas.rectangle(llx,lly, wid, hei );     canvas.fillstroke(); 

when draw lines , shapes in pdf, use path construction operators. following method introduces re (rectangle) operator construct rectangle.

canvas.rectangle(0,0,600,750); 

itext provides convenience methods. instance: following method introduces sequence of m (move to), l (line to), c (curve to),... operators:

canvas.roundrectangle(llx,lly, wid, hei, 10); 

as have constructed path, can use path painting operator draw something. itext has different fill(), stroke() , fillstroke() variations.

you using method:

canvas.fillstroke(); 

this means fill path fill color , stroke path stroke color. in question, indicate want fill path (you want color what's inside rounded rectangle); not want stroke (you don't want draw border of rounded rectangle).

this easy achieve. replace fillstroke() fill():

canvas.fill(); 

now fill rounded rectangle , not stroke border.

comment mkl:

a line width of 0 shall denote thinnest line can rendered @ device resolution: 1 device pixel wide.

this correct. common misconception changing width of line 0 means line isn't drawn when invoking stroke(). if don't want see line, solution simple: don't stroke it.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -