private void AddTabbedTextToParagraph(Paragraph p, String text, float[] positions, TabAlignment[] alignments , ILineDrawer[] tabLeadings, char?[] tabAnchorCharacters) { IList <TabStop> tabStops = new List <TabStop>(); for (int i = 0; i < positions.Length; ++i) { TabStop tabStop = new TabStop(positions[i], alignments[i], tabLeadings[i]); tabStop.SetTabAnchor(tabAnchorCharacters[i]); tabStops.Add(tabStop); } p.AddTabStops(tabStops); foreach (String line in iText.IO.Util.StringUtil.Split(text, "\n")) { foreach (String chunk in iText.IO.Util.StringUtil.Split(line, "\t")) { foreach (String piece in iText.IO.Util.StringUtil.Split(chunk, "#")) { if (!String.IsNullOrEmpty(piece)) { p.Add(piece); } } p.Add(new Tab()); } p.Add("\n"); } }
private void AddTabbedTextToParagraph(Paragraph p, String text, float[] positions, TabAlignment[] alignments , ILineDrawer[] tabLeadings, char?[] tabAnchorCharacters) { IList <TabStop> tabStops = new List <TabStop>(); for (int i = 0; i < positions.Length; ++i) { TabStop tabStop = new TabStop(positions[i], alignments[i], tabLeadings[i]); tabStop.SetTabAnchor(tabAnchorCharacters[i]); tabStops.Add(tabStop); } p.AddTabStops(tabStops); foreach (String line in text.Split("\n")) { foreach (String chunk in line.Split("\t")) { p.Add(chunk).Add(new Tab()); } p.Add("\n"); } }
public virtual void TabsAnchorSemicolonTest03() { String outFileName = destinationFolder + "tabsAnchorSemicolonTest03.pdf"; String cmpFileName = sourceFolder + "cmp_tabsAnchorSemicolonTest03.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDoc); float w = document.GetPageEffectiveArea(PageSize.A4).GetWidth(); Paragraph p = new Paragraph(); TabStop tabStop = new TabStop(w / 2, TabAlignment.ANCHOR); tabStop.SetTabAnchor(':'); p.AddTabStops(tabStop); p.Add(new Tab()).Add("Test:Answer"); document.Add(p); p = new Paragraph(); p.AddTabStops(tabStop); p.Add(new Tab()).Add("Test245454:Answer2"); document.Add(p); document.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder , "diff")); }
public virtual void CreatePdf(String dest) { PdfDocument pdf = new PdfDocument(new PdfWriter(dest)); Document document = new Document(pdf, PageSize.A4.Rotate()); float[] stops = new float[] { 80, 120, 580, 590, 720 }; IList <TabStop> tabstops = new List <TabStop>(); tabstops.Add(new TabStop(stops[0], TabAlignment.CENTER)); tabstops.Add(new TabStop(stops[1], TabAlignment.LEFT)); tabstops.Add(new TabStop(stops[2], TabAlignment.RIGHT)); tabstops.Add(new TabStop(stops[3], TabAlignment.LEFT)); TabStop anchor = new TabStop(stops[4], TabAlignment.ANCHOR); anchor.SetTabAnchor(' '); tabstops.Add(anchor); PdfCanvas pdfCanvas = new PdfCanvas(pdf.AddNewPage()); for (int i = 0; i < stops.Length; i++) { pdfCanvas.MoveTo(document.GetLeftMargin() + stops[i], 0); pdfCanvas.LineTo(document.GetLeftMargin() + stops[i], 595); } pdfCanvas.Stroke(); IList <IList <String> > resultSet = CsvTo2DList.Convert(SRC, "|"); foreach (IList <String> record in resultSet) { Paragraph p = new Paragraph(); p.AddTabStops(tabstops); p.Add(record[0].Trim()).Add(new Tab()).Add(record[1].Trim()).Add(new Tab()).Add(record[2].Trim()).Add(new Tab()).Add(record[3].Trim()).Add(new Tab()).Add(record[4].Trim()).Add(new Tab()).Add(record[5].Trim() + " \'"); document.Add(p); } document.Close(); }