Sunday 15 June 2014

c# - iTextSharp: which alignment properties are used in a PdfPCell? -


This works when I use cell alignment:

  PdfPCell Cell1 = new PDFPCL (new phrase ("text", font)); Cell 1 Horizontal alignment = 2;   

But once alignment does not work:

  pdfPCell cell1 = new PDFPCL (); Cell1.AddElement (new phrase ("text1", font)); Cell1.AddElement (new phrase ("text2", font)); Cell 1 Horizontal alignment = 2;   

Cause

You are misleading text mode < overall mode with / em>

In the first code snippet, you work in text mode . This means that the contents of the cell are considered to be text only and the properties of the cell are respected, while the properties of the elements added to the cell are ignored.

In the second code snippet, you work in the overall mode when you use the AddElement () method, then a cell overall Mode In this case, the properties of the cell are ignored. Instead, the properties of elements are used.

For example: In text mode, the contents of the cell can only have one type of alignment. In overall mode, you may have a paragraph that has been omitted from the coalition, is a paragraph that is centered, and a paragraph that is just aligned, all in one cell.

No comments:

Post a Comment