private bool CapitalizeAndReturnIsLastAlphabetic(iText.Layout.Element.Text element, String text, bool previousAlphabetic ) { StringBuilder sb = new StringBuilder(); bool previousLetter = previousAlphabetic; for (int i = 0; i < text.Length; i++) { if (char.IsLower(text[i]) && !previousLetter) { sb.Append(char.ToUpper(text[i])); previousLetter = true; } else { if (char.IsLetter(text[i])) { sb.Append(text[i]); previousLetter = true; } else { sb.Append(text[i]); previousLetter = false; } } } element.SetText(sb.ToString()); return(previousLetter); }
public virtual void TextOverflowTest02() { String outFileName = destinationFolder + "textOverflowTest02.pdf"; String cmpFileName = sourceFolder + "cmp_textOverflowTest02.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); iText.Layout.Element.Text overflowText = new iText.Layout.Element.Text("This is a long-long and large text which will not overflow" ).SetFontSize(19).SetFontColor(ColorConstants.RED); iText.Layout.Element.Text followText = new iText.Layout.Element.Text("This is a text which follows overflowed text and will be wrapped" ); document.Add(new Paragraph().Add(overflowText).Add(followText)); document.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder , "diff")); }
public virtual void PreLayoutTest02() { String outFileName = destinationFolder + "preLayoutTest02.pdf"; String cmpFileName = sourceFolder + "cmp_preLayoutTest02.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDoc, PageSize.Default, false); document.Add(new Paragraph("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")); StringBuilder text = new StringBuilder(); for (int i = 0; i < 1200; i++) { text.Append("A very long text is here..."); } Paragraph twoColumnParagraph = new Paragraph(); twoColumnParagraph.SetNextRenderer(new PreLayoutTest.TwoColumnParagraphRenderer(twoColumnParagraph)); iText.Layout.Element.Text textElement = new iText.Layout.Element.Text(text.ToString()); twoColumnParagraph.Add(textElement).SetFont(PdfFontFactory.CreateFont(StandardFonts.HELVETICA)); document.Add(twoColumnParagraph); document.Add(new Paragraph("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")); int paragraphLastPageNumber = -1; IList <IRenderer> documentChildRenderers = document.GetRenderer().GetChildRenderers(); for (int i = documentChildRenderers.Count - 1; i >= 0; i--) { if (documentChildRenderers[i].GetModelElement() == twoColumnParagraph) { paragraphLastPageNumber = documentChildRenderers[i].GetOccupiedArea().GetPageNumber(); break; } } twoColumnParagraph.SetNextRenderer(new PreLayoutTest.TwoColumnParagraphRenderer(twoColumnParagraph, paragraphLastPageNumber )); document.Relayout(); //Close document. Drawing of content is happened on close document.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder , "diff")); }