Note that there are some explanatory texts on larger screens.

plurals
  1. POitextsharp converting 1 column to 3 columns per page
    primarykey
    data
    text
    <p>I was wondering if i could get some help converting this into a 3 column (going down to left) per page report.</p> <pre><code>using System; using System.IO; using iTextSharp.text; using iTextSharp.text.pdf; namespace ConsoleApp { class Program { static void Main(string[] args) { Console.WriteLine("-&gt; Creates a PDF file with a block of Text."); Document document = new Document(PageSize.LETTER); try { PdfWriter writer = PdfWriter.GetInstance( document, new FileStream(@"c:\\temp\\column_example.pdf", FileMode.Create)); document.Open(); PdfContentByte cb = writer.DirectContent; float pos; PdfPTable table; PdfPCell cell = new PdfPCell(new Phrase(string.Empty)); Phrase phrase; float columnWidth = (PageSize.LETTER.Width - 36); ColumnText ct = GetColumn(cb, columnWidth); int status = 0; string line = "Line{0}"; for(int i=0; i&lt;50; i++) { table = new PdfPTable(1); table.SpacingAfter = 9F; cell = new PdfPCell(new Phrase("Header for table " + i)); table.AddCell(cell); for (int j = 0; j &lt; (i%2 == 0 ? 5 : 7); j++) { phrase = new Phrase(string.Format(line, i)); cell = new PdfPCell(phrase); table.AddCell(cell); } ct.AddElement(table); pos = ct.YLine; status = ct.Go(true); Console.WriteLine("Lines written:" + ct.LinesWritten + " Y-position: " + pos + " - " + ct.YLine); if (!ColumnText.HasMoreText(status)) { ct.AddElement(table); ct.YLine = pos; ct.Go(false); } else { document.NewPage(); ct.SetText(null); ct.AddElement(table); ct.YLine = PageSize.LETTER.Height - 36; ct.Go(); } } } catch (DocumentException de) { Console.Error.WriteLine(de.Message); } catch (IOException ioe) { Console.Error.WriteLine(ioe.Message); } finally { document.Close(); } Console.ReadLine(); } private static ColumnText GetColumn(PdfContentByte cb, float columnWidth) { var ct = new ColumnText(cb); ct.SetSimpleColumn(36, 36, columnWidth, PageSize.LETTER.Height - 36, 18, Element.ALIGN_JUSTIFIED); return ct; } } } </code></pre> <p>I'm really new with itextsharp and can't find any good examples on how to do this.</p> <p>Thanks for any help</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload