예제 #1
0
        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);
        }
예제 #2
0
        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"));
        }
예제 #3
0
        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"));
        }