| By Date: | <-- --> |
| By Thread: | <-- --> |
Darryl Miles wrote:
Singhal, Ramneek (Exchange) wrote:
A newbie question. How to draw a horizontal line (same as <HR> in html) in PDF using iText.
Document document = new Document(PageSize.A4, 36, 36, 36, 36); PdfWriter writer = PdfWriter.getInstance(document, out); PdfContentByte cb = writer.getDirectContent();
cb.setLineWidth(2.0f); // Make a bit thicker than 1.0 default cb.setGrayStroke(0.95f); // 1 = black, 0 = white float x = 72f; float 7 = 72f; cb.moveTo(x, y); cb.lineTo(x + 72f*6, y); cb.stroke();
That's a good example. A follow-up question could be: how do I know the value of y? There are different possibilities. PdfWriter has a method getVerticalPosition, but I like to use page events to draw lines, for instance using onParagraph or onGenericTag.
On a related note if you know how to do a relative lineTo in iText I would like to know, maybe PDF doesn't allow it ?
See table 4.9 on page 196-197 of the PDF Reference manual for a list with the 'path construction operators'. There is no relative lineTo... br, Bruno
------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ iText-questions mailing list iText-questions (at) lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions