c# - Draw Lines on Image in PDF using ItextSharp -



c# - Draw Lines on Image in PDF using ItextSharp -

i trying draw lines on image needs loaded on pdf document, draw graphics on paint event of control, fails so.

any suggestions ?

document pdfdoc = new document(pagesize.a2, 10f, 10f, 10f, 0f); pdfdoc.addheader("batting study - ", txtsearchbox.text); itextsharp.text.image pic = itextsharp.text.image.getinstance(properties.resources.bgww , system.drawing.imaging.imageformat.jpeg); pdfwriter author = pdfwriter.getinstance(pdfdoc, stream); pdfdoc.open(); pdfdoc.add(pic);

so, how modify pic object of itextsharpimage can draw lines on image?

please take @ watermarkedimages4 example. based on watermarkedimages1 illustration referred in comments. different between 2 examples add together text in illustration written in reply how add together text image? whereas add together lines in illustration written in reply question.

we add together images this:

document.add(getwatermarkedimage(cb, image.getinstance(image1)));

the getwatermarkedimage() method looks this:

public image getwatermarkedimage(pdfcontentbyte cb, image img) throws documentexception { float width = img.getscaledwidth(); float height = img.getscaledheight(); pdftemplate template = cb.createtemplate(width, height); template.addimage(img, width, 0, 0, height, 0, 0); template.savestate(); template.setcolorstroke(basecolor.green); template.setlinewidth(3); template.moveto(width * .25f, height * .25f); template.lineto(width * .75f, height * .75f); template.moveto(width * .25f, height * .75f); template.lineto(width * .25f, height * .25f); template.stroke(); template.setcolorstroke(basecolor.white); template.ellipse(0, 0, width, height); template.stroke(); template.restorestate(); homecoming image.getinstance(template); }

as can see, add together 2 greenish lines using moveto(), lineto() , stroke(). add together white ellipse using ellipse() , stroke() method.

this results in pdf looks this:

as can see, shape of ellipse , position of lines different different images because defined coordinates based on width , height of image.

c# visual-studio-2010 pdf itextsharp

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -