itextsharp - Color Document Sections in iText Sharp -


help, need create pdf itextsharp has 1) green background entire document 2) text (headings, tables, paragraphs) appear on white background. 3) special sections appear pink (or other color) 4) headings on blue background white text.

i can build simple document, background colors throwing me off.

i add content using paragraphs, i'm not sure how set background color of paragraph, or group them together.

enter image description here

you create document using objects such paragraphs, pdfptables, , on. draw rectangles using pdfcontentbyte methods. obtain pdfcontentbyte instance pdfwriter this:

writer.getdirectcontentunder(); // java 

or

writer.directcontentunder; // c# 

by using getdirectcontentunder() instead of getdirectcontent(), rectangles drawn under paragraphs, pdfptables, , on.

your main problem keeping track of coordinates: need know coordinate of lower-left corner , of upper-right corner.

drawing background full page no-brainer. i've answered question yesterday: how draw border whole pdf pages using itext library 5.5.2

granted, in answer defined border color rectangle because op needed red border on each page. need define fill color of rectangle instead of border.

by examining answer yesterday's question, you'll discover concept of page events. you'll discover other page event methods, such onparagraph() , onparagraphend(). these methods receive y coordinate of start of each paragraph , end of each paragraph. can use these coordinates draw rectangles in page event.

to solve problem, add basecolor member variable, variable keeps track of initial y value, , on. require programming, mechanisms explained in answer, should able meet requirement.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -