Beispiel #1
0
        public virtual void TestPdfLayersWithDefaultNames()
        {
            String              path = PdfHelper.GetDefaultImagePath();
            FileInfo            file = new FileInfo(path);
            OcrEngineProperties ocrEngineProperties = new OcrEngineProperties();

            ocrEngineProperties.SetLanguages(JavaCollectionsUtil.SingletonList <String>("eng"));
            CustomOcrEngine engine        = new CustomOcrEngine(ocrEngineProperties);
            OcrPdfCreator   ocrPdfCreator = new OcrPdfCreator(engine);
            PdfDocument     doc           = ocrPdfCreator.CreatePdf(JavaCollectionsUtil.SingletonList <FileInfo>(file), PdfHelper.GetPdfWriter
                                                                        ());

            NUnit.Framework.Assert.IsNotNull(doc);
            IList <PdfLayer> layers = doc.GetCatalog().GetOCProperties(true).GetLayers();

            NUnit.Framework.Assert.AreEqual(0, layers.Count);
            doc.Close();
            NUnit.Framework.Assert.AreEqual(engine, ocrPdfCreator.GetOcrEngine());
            NUnit.Framework.Assert.AreEqual(1, engine.GetOcrEngineProperties().GetLanguages().Count);
            NUnit.Framework.Assert.AreEqual("eng", engine.GetOcrEngineProperties().GetLanguages()[0]);
        }
Beispiel #2
0
        public virtual String GetResultantText()
        {
            if (DUMP_STATE)
            {
                DumpState();
            }
            IList <LocationTextExtractionStrategy.TextChunk> textChunks = locationalResult;

            JavaCollectionsUtil.Sort(textChunks);
            StringBuilder sb = new StringBuilder();

            LocationTextExtractionStrategy.TextChunk lastChunk = null;
            foreach (LocationTextExtractionStrategy.TextChunk chunk in textChunks)
            {
                if (lastChunk == null)
                {
                    sb.Append(chunk.text);
                }
                else
                {
                    if (chunk.SameLine(lastChunk))
                    {
                        // we only insert a blank space if the trailing character of the previous string wasn't a space, and the leading character of the current string isn't a space
                        if (IsChunkAtWordBoundary(chunk, lastChunk) && !StartsWithSpace(chunk.text) && !EndsWithSpace(lastChunk.text
                                                                                                                      ))
                        {
                            sb.Append(' ');
                        }
                        sb.Append(chunk.text);
                    }
                    else
                    {
                        sb.Append('\n');
                        sb.Append(chunk.text);
                    }
                }
                lastChunk = chunk;
            }
            return(sb.ToString());
        }
 private static PdfDictionary CopyNamespaceDict(PdfDictionary srcNsDict, StructureTreeCopier.StructElemCopyingParams
      copyingParams) {
     IList<PdfName> excludeKeys = JavaCollectionsUtil.SingletonList<PdfName>(PdfName.RoleMapNS);
     PdfDocument toDocument = copyingParams.GetToDocument();
     PdfDictionary copiedNsDict = srcNsDict.CopyTo(toDocument, excludeKeys, false);
     copyingParams.AddCopiedNamespace(copiedNsDict);
     PdfDictionary srcRoleMapNs = srcNsDict.GetAsDictionary(PdfName.RoleMapNS);
     // if this src namespace was already copied (or in the process of copying) it will contain role map already
     PdfDictionary copiedRoleMap = copiedNsDict.GetAsDictionary(PdfName.RoleMapNS);
     if (srcRoleMapNs != null && copiedRoleMap == null) {
         copiedRoleMap = new PdfDictionary();
         copiedNsDict.Put(PdfName.RoleMapNS, copiedRoleMap);
         foreach (KeyValuePair<PdfName, PdfObject> entry in srcRoleMapNs.EntrySet()) {
             PdfObject copiedMapping;
             if (entry.Value.IsArray()) {
                 PdfArray srcMappingArray = (PdfArray)entry.Value;
                 if (srcMappingArray.Size() > 1 && srcMappingArray.Get(1).IsDictionary()) {
                     PdfArray copiedMappingArray = new PdfArray();
                     copiedMappingArray.Add(srcMappingArray.Get(0).CopyTo(toDocument));
                     PdfDictionary copiedNamespace = CopyNamespaceDict(srcMappingArray.GetAsDictionary(1), copyingParams);
                     copiedMappingArray.Add(copiedNamespace);
                     copiedMapping = copiedMappingArray;
                 }
                 else {
                     ILog logger = LogManager.GetLogger(typeof(StructureTreeCopier));
                     logger.Warn(String.Format(iText.IO.LogMessageConstant.ROLE_MAPPING_FROM_SOURCE_IS_NOT_COPIED_INVALID, entry
                         .Key.ToString()));
                     continue;
                 }
             }
             else {
                 copiedMapping = entry.Value.CopyTo(toDocument);
             }
             PdfName copiedRoleFrom = (PdfName)entry.Key.CopyTo(toDocument);
             copiedRoleMap.Put(copiedRoleFrom, copiedMapping);
         }
     }
     return copiedNsDict;
 }
Beispiel #4
0
        public virtual void TestPdfLayersWithCustomNames()
        {
            String   path = PdfHelper.GetDefaultImagePath();
            FileInfo file = new FileInfo(path);
            OcrPdfCreatorProperties properties = new OcrPdfCreatorProperties();

            properties.SetImageLayerName("name image 1");
            properties.SetTextLayerName("name text 1");
            OcrPdfCreator ocrPdfCreator = new OcrPdfCreator(new CustomOcrEngine(), properties);
            PdfDocument   doc           = ocrPdfCreator.CreatePdf(JavaCollectionsUtil.SingletonList <FileInfo>(file), PdfHelper.GetPdfWriter
                                                                      ());

            NUnit.Framework.Assert.IsNotNull(doc);
            IList <PdfLayer> layers = doc.GetCatalog().GetOCProperties(true).GetLayers();

            NUnit.Framework.Assert.AreEqual(2, layers.Count);
            NUnit.Framework.Assert.AreEqual("name image 1", layers[0].GetPdfObject().Get(PdfName.Name).ToString());
            NUnit.Framework.Assert.IsTrue(layers[0].IsOn());
            NUnit.Framework.Assert.AreEqual("name text 1", layers[1].GetPdfObject().Get(PdfName.Name).ToString());
            NUnit.Framework.Assert.IsTrue(layers[1].IsOn());
            doc.Close();
        }
Beispiel #5
0
        public virtual int MoveKidHint(TaggingHintKey hintKeyOfKidToMove, TaggingHintKey newParent, int insertIndex
                                       )
        {
            if (newParent.IsFinished())
            {
                ILog logger = LogManager.GetLogger(typeof(iText.Layout.Tagging.LayoutTaggingHelper));
                logger.Error(iText.IO.LogMessageConstant.CANNOT_MOVE_HINT_TO_FINISHED_PARENT);
                return(-1);
            }
            int removeRes = RemoveParentHint(hintKeyOfKidToMove);

            if (removeRes == RETVAL_PARENT_AND_KID_FINISHED || removeRes == RETVAL_NO_PARENT && hintKeyOfKidToMove.IsFinished
                    ())
            {
                ILog logger = LogManager.GetLogger(typeof(iText.Layout.Tagging.LayoutTaggingHelper));
                logger.Error(iText.IO.LogMessageConstant.CANNOT_MOVE_FINISHED_HINT);
                return(-1);
            }
            AddKidsHint(newParent, JavaCollectionsUtil.SingletonList <TaggingHintKey>(hintKeyOfKidToMove), insertIndex,
                        true);
            return(removeRes);
        }
Beispiel #6
0
        private IList <char[]> SplitOnNonCharacters(char[] word)
        {
            IList <int> breakPoints = GetNonLetterBreaks(word);

            if (breakPoints.Count == 0)
            {
                return(JavaCollectionsUtil.EmptyList <char[]>());
            }
            IList <char[]> words = new List <char[]>();

            for (int ibreak = 0; ibreak < breakPoints.Count; ibreak++)
            {
                char[] newWord = GetWordFromCharArray(word, ((ibreak == 0) ? 0 : breakPoints[ibreak - 1]), breakPoints[ibreak
                                                      ]);
                words.Add(newWord);
            }
            if (word.Length - breakPoints[breakPoints.Count - 1] - 1 > 1)
            {
                char[] newWord = GetWordFromCharArray(word, breakPoints[breakPoints.Count - 1], word.Length);
                words.Add(newWord);
            }
            return(words);
        }
            /* (non-Javadoc)
             * @see com.itextpdf.html2pdf.css.resolve.HtmlStylesToCssConverter.IAttributeConverter#convert(com.itextpdf.styledxmlparser.html.node.IElementNode, java.lang.String)
             */
            public virtual IList <CssDeclaration> Convert(IElementNode element, String value)
            {
                float?width = CssUtils.ParseFloat(value);

                if (width != null)
                {
                    if (TagConstants.TABLE.Equals(element.Name()) && width != 0)
                    {
                        IList <CssDeclaration>       declarations = new BorderShorthandResolver().ResolveShorthand("1px solid");
                        IDictionary <String, String> styles       = new Dictionary <String, String>(declarations.Count);
                        foreach (CssDeclaration declaration in declarations)
                        {
                            styles.Put(declaration.GetProperty(), declaration.GetExpression());
                        }
                        ApplyBordersToTableCells(element, styles);
                    }
                    if (width >= 0)
                    {
                        return(JavaUtil.ArraysAsList(new CssDeclaration(CssConstants.BORDER, value + "px solid")));
                    }
                }
                return(JavaCollectionsUtil.EmptyList <CssDeclaration>());
            }
Beispiel #8
0
        public virtual IList <TaggingHintKey> GetAccessibleKidsHint(TaggingHintKey parent)
        {
            IList <TaggingHintKey> kidsHint = kidsHints.Get(parent);

            if (kidsHint == null)
            {
                return(JavaCollectionsUtil.EmptyList <TaggingHintKey>());
            }
            IList <TaggingHintKey> accessibleKids = new List <TaggingHintKey>();

            foreach (TaggingHintKey kid in kidsHint)
            {
                if (IsNonAccessibleHint(kid))
                {
                    accessibleKids.AddAll(GetAccessibleKidsHint(kid));
                }
                else
                {
                    accessibleKids.Add(kid);
                }
            }
            return(accessibleKids);
        }
        public virtual void SearchFontAliasWithUnicodeChars()
        {
            // фонт1
            String cyrillicAlias = "\u0444\u043E\u043D\u04421";
            // γραμματοσειρά2
            String greekAlias = "\u03B3\u03C1\u03B1\u03BC\u03BC\u03B1\u03C4\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC2";
            // フォント3
            String japaneseAlias = "\u30D5\u30A9\u30F3\u30C83";
            IDictionary <String, String> aliasToFontName = new LinkedDictionary <String, String>();

            aliasToFontName.Put(cyrillicAlias, "NotoSans-Regular.ttf");
            aliasToFontName.Put(greekAlias, "FreeSans.ttf");
            aliasToFontName.Put(japaneseAlias, "Puritan2.otf");
            FontProvider provider = new FontProvider();

            foreach (KeyValuePair <String, String> e in aliasToFontName)
            {
                provider.GetFontSet().AddFont(fontsFolder + e.Value, PdfEncodings.IDENTITY_H, e.Key);
            }
            ICollection <String> actualAliases = new HashSet <String>();

            foreach (FontInfo fontInfo in provider.GetFontSet().GetFonts())
            {
                actualAliases.Add(fontInfo.GetAlias());
            }
            ICollection <String> expectedAliases = aliasToFontName.Keys;

            NUnit.Framework.Assert.IsTrue(actualAliases.ContainsAll(expectedAliases) && expectedAliases.ContainsAll(actualAliases
                                                                                                                    ));
            foreach (String fontAlias in expectedAliases)
            {
                PdfFont pdfFont = provider.GetPdfFont(provider.GetFontSelector(JavaCollectionsUtil.SingletonList(fontAlias
                                                                                                                 ), new FontCharacteristics()).BestMatch());
                String fontName = pdfFont.GetFontProgram().GetFontNames().GetFontName();
                NUnit.Framework.Assert.IsTrue(aliasToFontName.Get(fontAlias).Contains(fontName));
            }
        }
        public virtual ICollection <IPdfTextLocation> GetResultantLocations()
        {
            // align characters in "logical" order
            JavaCollectionsUtil.Sort(parseResult, new TextChunkLocationBasedComparator(new DefaultTextChunkLocationComparator()));
            // process parse results
            IList <IPdfTextLocation> retval = new List <IPdfTextLocation>();

            CharacterRenderInfo.StringConversionInfo txt = CharacterRenderInfo.MapString(parseResult);
            Match mat = iText.IO.Util.StringUtil.Match(pattern, txt.text);

            while (mat.Success)
            {
                int?startIndex = GetStartIndex(txt.indexMap, mat.Index, txt.text);
                int?endIndex   = GetEndIndex(txt.indexMap, mat.Index + mat.Length - 1);
                if (startIndex != null && endIndex != null && startIndex <= endIndex)
                {
                    foreach (Rectangle r in ToRectangles(parseResult.SubList(startIndex.Value, endIndex.Value + 1)))
                    {
                        retval.Add(new DefaultPdfTextLocation(0, r, iText.IO.Util.StringUtil.Group(mat, 0)));
                    }
                }

                mat = mat.NextMatch();
            }

            /* sort
             * even though the return type is Collection<Rectangle>, we apply a sorting algorithm here
             * This is to ensure that tests that use this functionality (for instance to generate pdf with
             * areas of interest highlighted) will not break when compared.
             */
            JavaCollectionsUtil.Sort(retval, new _IComparer_54());

            // ligatures can produces same rectangle
            removeDuplicates(retval);

            return(retval);
        }
Beispiel #11
0
        public virtual void TestTextFromPdfLayersFromMultiPageTiff()
        {
            String   testName   = "testTextFromPdfLayersFromMultiPageTiff";
            bool     preprocess = tesseractReader.GetTesseract4OcrEngineProperties().IsPreprocessingImages();
            String   path       = TEST_IMAGES_DIRECTORY + "multîpage.tiff";
            String   pdfPath    = GetTargetDirectory() + testName + ".pdf";
            FileInfo file       = new FileInfo(path);

            tesseractReader.SetTesseract4OcrEngineProperties(tesseractReader.GetTesseract4OcrEngineProperties().SetPreprocessingImages
                                                                 (false));
            OcrPdfCreatorProperties properties = new OcrPdfCreatorProperties();

            properties.SetTextLayerName("Text Layer");
            properties.SetImageLayerName("Image Layer");
            OcrPdfCreator ocrPdfCreator = new OcrPdfCreator(tesseractReader, properties);
            PdfDocument   doc           = ocrPdfCreator.CreatePdf(JavaCollectionsUtil.SingletonList <FileInfo>(file), GetPdfWriter(
                                                                      pdfPath));

            NUnit.Framework.Assert.IsNotNull(doc);
            int numOfPages          = doc.GetNumberOfPages();
            IList <PdfLayer> layers = doc.GetCatalog().GetOCProperties(true).GetLayers();

            NUnit.Framework.Assert.AreEqual(numOfPages * 2, layers.Count);
            NUnit.Framework.Assert.AreEqual("Image Layer", layers[2].GetPdfObject().Get(PdfName.Name).ToString());
            NUnit.Framework.Assert.AreEqual("Text Layer", layers[3].GetPdfObject().Get(PdfName.Name).ToString());
            doc.Close();
            // Text layer should contain all text
            // Image layer shouldn't contain any text
            String expectedOutput = "Multipage\nTIFF\nExample\nPage 5";

            NUnit.Framework.Assert.AreEqual(expectedOutput, GetTextFromPdfLayer(pdfPath, "Text Layer", 5));
            NUnit.Framework.Assert.AreEqual("", GetTextFromPdfLayer(pdfPath, "Image Layer", 5));
            NUnit.Framework.Assert.IsFalse(tesseractReader.GetTesseract4OcrEngineProperties().IsPreprocessingImages());
            tesseractReader.SetTesseract4OcrEngineProperties(tesseractReader.GetTesseract4OcrEngineProperties().SetPreprocessingImages
                                                                 (preprocess));
        }
Beispiel #12
0
        public virtual void TestSpanishPNG()
        {
            String         testName                  = "compareSpanishPNG";
            String         filename                  = "scanned_spa_01";
            String         expectedText1             = "¿Y SI ENSAYARA COMO ACTUAR?";
            String         expectedText2             = "¿Y SI ENSAYARA ACTUAR?";
            String         resultPdfPath             = GetTargetDirectory() + filename + "_" + testName + "_" + testFileTypeName + ".pdf";
            IList <String> languages                 = JavaUtil.ArraysAsList("spa", "spa_old");
            Tesseract4OcrEngineProperties properties = tesseractReader.GetTesseract4OcrEngineProperties();

            if (isExecutableReaderType)
            {
                properties.SetPreprocessingImages(false);
            }
            // locate text by words
            properties.SetTextPositioning(TextPositioning.BY_WORDS);
            properties.SetLanguages(languages);
            tesseractReader.SetTesseract4OcrEngineProperties(properties);
            OcrPdfCreatorProperties ocrPdfCreatorProperties = new OcrPdfCreatorProperties();

            ocrPdfCreatorProperties.SetTextColor(DeviceCmyk.BLACK);
            OcrPdfCreator ocrPdfCreator = new OcrPdfCreator(tesseractReader, ocrPdfCreatorProperties);

            using (PdfWriter pdfWriter = GetPdfWriter(resultPdfPath)) {
                ocrPdfCreator.CreatePdf(JavaCollectionsUtil.SingletonList <FileInfo>(new FileInfo(TEST_IMAGES_DIRECTORY + filename
                                                                                                  + ".png")), pdfWriter).Close();
            }
            try {
                String result = GetTextFromPdfLayer(resultPdfPath, null, 1).Replace("\n", " ");
                NUnit.Framework.Assert.IsTrue(result.Contains(expectedText1) || result.Contains(expectedText2));
            }
            finally {
                NUnit.Framework.Assert.AreEqual(TextPositioning.BY_WORDS, tesseractReader.GetTesseract4OcrEngineProperties
                                                    ().GetTextPositioning());
            }
        }
Beispiel #13
0
        private static void RunTest(String fileName, String fuzzValue)
        {
            String input  = inputPath + fileName + ".pdf";
            String output = outputPath + fileName + "_cleaned.pdf";
            String cmp    = inputPath + "cmp_" + fileName + ".pdf";
            IList <iText.PdfCleanup.PdfCleanUpLocation> cleanUpLocations = JavaCollectionsUtil.SingletonList(new iText.PdfCleanup.PdfCleanUpLocation
                                                                                                                 (1, new Rectangle(308, 520, 200, 75)));
            PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output));

            PdfCleaner.CleanUp(pdfDocument, cleanUpLocations);
            pdfDocument.Close();
            CleanUpImagesCompareTool cmpTool = new CleanUpImagesCompareTool();
            String errorMessage           = cmpTool.ExtractAndCompareImages(output, cmp, outputPath, fuzzValue);
            String compareByContentResult = cmpTool.CompareByContent(output, cmp, outputPath);

            if (compareByContentResult != null)
            {
                errorMessage += compareByContentResult;
            }
            if (!errorMessage.Equals(""))
            {
                NUnit.Framework.Assert.Fail(errorMessage);
            }
        }
Beispiel #14
0
 /* (non-Javadoc)
  * @see com.itextpdf.html2pdf.html.node.INode#childNodes()
  */
 public virtual IList <INode> ChildNodes()
 {
     return(JavaCollectionsUtil.EmptyList <INode>());
 }
Beispiel #15
0
        public override AccessibilityProperties AddAttributes(int index, PdfStructureAttributes attributes)
        {
            if (attributes == null)
            {
                return(this);
            }
            PdfObject attributesObject   = GetBackingElem().GetAttributes(false);
            PdfObject combinedAttributes = AccessibilityPropertiesToStructElem.CombineAttributesList(attributesObject,
                                                                                                     index, JavaCollectionsUtil.SingletonList(attributes), GetBackingElem().GetPdfObject().GetAsNumber(PdfName
                                                                                                                                                                                                       .R));

            GetBackingElem().SetAttributes(combinedAttributes);
            return(this);
        }
Beispiel #16
0
 public IList <ISvgNodeRenderer> GetChildren()
 {
     // final method, in order to disallow modifying the List
     return(JavaCollectionsUtil.UnmodifiableList(children));
 }
        public virtual bool OnTagFinish(LayoutTaggingHelper taggingHelper, TaggingHintKey tableHintKey)
        {
            IList <TaggingHintKey> kidKeys = taggingHelper.GetAccessibleKidsHint(tableHintKey);
            IDictionary <int, SortedDictionary <int, TaggingHintKey> > tableTags = new SortedDictionary <int, SortedDictionary
                                                                                                         <int, TaggingHintKey> >();
            IList <TaggingHintKey> tableCellTagsUnindexed = new List <TaggingHintKey>();
            IList <TaggingHintKey> nonCellKids            = new List <TaggingHintKey>();

            foreach (TaggingHintKey kidKey in kidKeys)
            {
                if (StandardRoles.TD.Equals(kidKey.GetAccessibleElement().GetAccessibilityProperties().GetRole()) || StandardRoles
                    .TH.Equals(kidKey.GetAccessibleElement().GetAccessibilityProperties().GetRole()))
                {
                    if (kidKey.GetAccessibleElement() is Cell)
                    {
                        Cell cell   = (Cell)kidKey.GetAccessibleElement();
                        int  rowInd = cell.GetRow();
                        int  colInd = cell.GetCol();
                        SortedDictionary <int, TaggingHintKey> rowTags = tableTags.Get(rowInd);
                        if (rowTags == null)
                        {
                            rowTags = new SortedDictionary <int, TaggingHintKey>();
                            tableTags.Put(rowInd, rowTags);
                        }
                        rowTags.Put(colInd, kidKey);
                    }
                    else
                    {
                        tableCellTagsUnindexed.Add(kidKey);
                    }
                }
                else
                {
                    nonCellKids.Add(kidKey);
                }
            }
            bool createTBody = true;

            if (tableHintKey.GetAccessibleElement() is Table)
            {
                Table modelElement = (Table)tableHintKey.GetAccessibleElement();
                createTBody = modelElement.GetHeader() != null && !modelElement.IsSkipFirstHeader() || modelElement.GetFooter
                                  () != null && !modelElement.IsSkipLastFooter();
            }
            TaggingDummyElement tbodyTag = null;

            tbodyTag = new TaggingDummyElement(createTBody ? StandardRoles.TBODY : null);
            foreach (TaggingHintKey nonCellKid in nonCellKids)
            {
                String kidRole = nonCellKid.GetAccessibleElement().GetAccessibilityProperties().GetRole();
                if (!StandardRoles.THEAD.Equals(kidRole) && !StandardRoles.TFOOT.Equals(kidRole))
                {
                    taggingHelper.MoveKidHint(nonCellKid, tableHintKey);
                }
            }
            foreach (TaggingHintKey nonCellKid in nonCellKids)
            {
                String kidRole = nonCellKid.GetAccessibleElement().GetAccessibilityProperties().GetRole();
                if (StandardRoles.THEAD.Equals(kidRole))
                {
                    taggingHelper.MoveKidHint(nonCellKid, tableHintKey);
                }
            }
            taggingHelper.AddKidsHint(tableHintKey, JavaCollectionsUtil.SingletonList <TaggingHintKey>(LayoutTaggingHelper
                                                                                                       .GetOrCreateHintKey(tbodyTag)), -1);
            foreach (TaggingHintKey nonCellKid in nonCellKids)
            {
                String kidRole = nonCellKid.GetAccessibleElement().GetAccessibilityProperties().GetRole();
                if (StandardRoles.TFOOT.Equals(kidRole))
                {
                    taggingHelper.MoveKidHint(nonCellKid, tableHintKey);
                }
            }
            foreach (SortedDictionary <int, TaggingHintKey> rowTags in tableTags.Values)
            {
                TaggingDummyElement row        = new TaggingDummyElement(StandardRoles.TR);
                TaggingHintKey      rowTagHint = LayoutTaggingHelper.GetOrCreateHintKey(row);
                foreach (TaggingHintKey cellTagHint in rowTags.Values)
                {
                    taggingHelper.MoveKidHint(cellTagHint, rowTagHint);
                }
                if (tableCellTagsUnindexed != null)
                {
                    foreach (TaggingHintKey cellTagHint in tableCellTagsUnindexed)
                    {
                        taggingHelper.MoveKidHint(cellTagHint, rowTagHint);
                    }
                    tableCellTagsUnindexed = null;
                }
                taggingHelper.AddKidsHint(tbodyTag, JavaCollectionsUtil.SingletonList <TaggingDummyElement>(row), -1);
            }
            return(true);
        }
        private static PageFlushingHelper.DeepFlushingContext InitPageFlushingContext()
        {
            ICollection <PdfName> ALL_KEYS_IN_BLACK_LIST = null;
            IDictionary <PdfName, PageFlushingHelper.DeepFlushingContext> NO_INNER_CONTEXTS = JavaCollectionsUtil.EmptyMap
                                                                                              <PdfName, PageFlushingHelper.DeepFlushingContext>();

            // --- action dictionary context ---
            PageFlushingHelper.DeepFlushingContext actionContext = new PageFlushingHelper.DeepFlushingContext(new LinkedHashSet
                                                                                                              <PdfName>(JavaUtil.ArraysAsList(PdfName.D, PdfName.SD, PdfName.Dp, PdfName.B, PdfName.Annotation, PdfName
                                                                                                                                              .T, PdfName.AN, PdfName.TA)), NO_INNER_CONTEXTS);
            // actions keys flushing blacklist
            PageFlushingHelper.DeepFlushingContext aaContext = new PageFlushingHelper.DeepFlushingContext(actionContext
                                                                                                          );
            // all inner entries leading to this context
            // ---
            // --- annotation dictionary context ---
            LinkedDictionary <PdfName, PageFlushingHelper.DeepFlushingContext> annotInnerContexts = new LinkedDictionary
                                                                                                    <PdfName, PageFlushingHelper.DeepFlushingContext>();

            PageFlushingHelper.DeepFlushingContext annotsContext = new PageFlushingHelper.DeepFlushingContext(new LinkedHashSet
                                                                                                              <PdfName>(JavaUtil.ArraysAsList(PdfName.P, PdfName.Popup, PdfName.Dest, PdfName.Parent, PdfName.V)), annotInnerContexts
                                                                                                              );
            // annotations flushing blacklist
            // keys that belong to form fields which can be merged with widget annotations
            annotInnerContexts.Put(PdfName.A, actionContext);
            annotInnerContexts.Put(PdfName.PA, actionContext);
            annotInnerContexts.Put(PdfName.AA, aaContext);
            // ---
            // --- separation info dictionary context ---
            PageFlushingHelper.DeepFlushingContext sepInfoContext = new PageFlushingHelper.DeepFlushingContext(new LinkedHashSet
                                                                                                               <PdfName>(JavaCollectionsUtil.SingletonList(PdfName.Pages)), NO_INNER_CONTEXTS);
            // separation info dict flushing blacklist
            // ---
            // --- bead dictionary context ---
            PageFlushingHelper.DeepFlushingContext bContext = new PageFlushingHelper.DeepFlushingContext(ALL_KEYS_IN_BLACK_LIST
                                                                                                         , NO_INNER_CONTEXTS);
            // bead dict flushing blacklist
            // ---
            // --- pres steps dictionary context ---
            LinkedDictionary <PdfName, PageFlushingHelper.DeepFlushingContext> presStepsInnerContexts = new LinkedDictionary
                                                                                                        <PdfName, PageFlushingHelper.DeepFlushingContext>();

            PageFlushingHelper.DeepFlushingContext presStepsContext = new PageFlushingHelper.DeepFlushingContext(new LinkedHashSet
                                                                                                                 <PdfName>(JavaCollectionsUtil.SingletonList(PdfName.Prev)), presStepsInnerContexts);
            // pres step dict flushing blacklist
            presStepsInnerContexts.Put(PdfName.NA, actionContext);
            presStepsInnerContexts.Put(PdfName.PA, actionContext);
            // ---
            // --- page dictionary context ---
            LinkedDictionary <PdfName, PageFlushingHelper.DeepFlushingContext> pageInnerContexts = new LinkedDictionary
                                                                                                   <PdfName, PageFlushingHelper.DeepFlushingContext>();

            PageFlushingHelper.DeepFlushingContext pageContext = new PageFlushingHelper.DeepFlushingContext(new LinkedHashSet
                                                                                                            <PdfName>(JavaUtil.ArraysAsList(PdfName.Parent, PdfName.DPart)), pageInnerContexts);
            pageInnerContexts.Put(PdfName.Annots, annotsContext);
            pageInnerContexts.Put(PdfName.B, bContext);
            pageInnerContexts.Put(PdfName.AA, aaContext);
            pageInnerContexts.Put(PdfName.SeparationInfo, sepInfoContext);
            pageInnerContexts.Put(PdfName.PresSteps, presStepsContext);
            // ---
            return(pageContext);
        }
 public DeepFlushingContext(PageFlushingHelper.DeepFlushingContext unconditionalInnerContext)
 {
     this.blackList                 = JavaCollectionsUtil.EmptySet <PdfName>();
     this.innerContexts             = null;
     this.unconditionalInnerContext = unconditionalInnerContext;
 }
Beispiel #20
0
 /* (non-Javadoc)
  * @see com.itextpdf.styledxmlparser.html.node.INode#childNodes()
  */
 public virtual IList <INode> ChildNodes()
 {
     return(JavaCollectionsUtil.UnmodifiableList(childNodes));
 }
Beispiel #21
0
 public virtual IList <PdfStructureAttributes> GetAttributesList()
 {
     return(JavaCollectionsUtil.EmptyList <PdfStructureAttributes>());
 }
        /// <summary>Gets an unmodifiable collection of marked content references on page.</summary>
        /// <remarks>
        /// Gets an unmodifiable collection of marked content references on page.
        /// NOTE: Do not remove tags when iterating over returned collection, this could
        /// lead to the ConcurrentModificationException, because returned collection is backed by the internal list of the
        /// actual page tags.
        /// </remarks>
        public virtual ICollection <PdfMcr> GetPageMarkedContentReferences(PdfPage page)
        {
            IDictionary <int, PdfMcr> pageMcrs = GetParentTreeHandler().GetPageMarkedContentReferences(page);

            return(pageMcrs != null?JavaCollectionsUtil.UnmodifiableCollection(pageMcrs.Values) : null);
        }
Beispiel #23
0
 /// <summary>Create new FontSelector instance.</summary>
 /// <param name="allFonts">Unsorted set of all available fonts.</param>
 /// <param name="fontFamilies">Sorted list of preferred font families.</param>
 /// <param name="fc"/>
 public FontSelector(ICollection <FontInfo> allFonts, IList <String> fontFamilies, FontCharacteristics fc)
 {
     this.fonts = new List <FontInfo>(allFonts);
     //Possible issue in .NET, virtual protected member in constructor.
     JavaCollectionsUtil.Sort(this.fonts, GetComparator(fontFamilies, fc));
 }
        protected internal virtual LayoutResult DirectLayout(LayoutContext layoutContext)
        {
            bool                   wasHeightClipped        = false;
            bool                   wasParentsHeightClipped = layoutContext.IsClippedHeight();
            int                    pageNumber               = layoutContext.GetArea().GetPageNumber();
            bool                   anythingPlaced           = false;
            bool                   firstLineInBox           = true;
            LineRenderer           currentRenderer          = (LineRenderer) new LineRenderer().SetParent(this);
            Rectangle              parentBBox               = layoutContext.GetArea().GetBBox().Clone();
            MarginsCollapseHandler marginsCollapseHandler   = null;
            bool                   marginsCollapsingEnabled = true.Equals(GetPropertyAsBoolean(Property.COLLAPSING_MARGINS));

            if (marginsCollapsingEnabled)
            {
                marginsCollapseHandler = new MarginsCollapseHandler(this, layoutContext.GetMarginsCollapseInfo());
            }
            OverflowPropertyValue?overflowX = this.GetProperty <OverflowPropertyValue?>(Property.OVERFLOW_X);
            bool?nowrapProp = this.GetPropertyAsBoolean(Property.NO_SOFT_WRAP_INLINE);

            currentRenderer.SetProperty(Property.NO_SOFT_WRAP_INLINE, nowrapProp);
            bool notAllKidsAreFloats = false;
            IList <Rectangle>  floatRendererAreas = layoutContext.GetFloatRendererAreas();
            FloatPropertyValue?floatPropertyValue = this.GetProperty <FloatPropertyValue?>(Property.FLOAT);
            float clearHeightCorrection           = FloatingHelper.CalculateClearHeightCorrection(this, floatRendererAreas, parentBBox
                                                                                                  );

            FloatingHelper.ApplyClearance(parentBBox, marginsCollapseHandler, clearHeightCorrection, FloatingHelper.IsRendererFloating
                                              (this));
            float?blockWidth = RetrieveWidth(parentBBox.GetWidth());

            if (FloatingHelper.IsRendererFloating(this, floatPropertyValue))
            {
                blockWidth = FloatingHelper.AdjustFloatedBlockLayoutBox(this, parentBBox, blockWidth, floatRendererAreas,
                                                                        floatPropertyValue, overflowX);
                floatRendererAreas = new List <Rectangle>();
            }
            if (0 == childRenderers.Count)
            {
                anythingPlaced  = true;
                currentRenderer = null;
            }
            bool  isPositioned              = IsPositioned();
            float?rotation                  = this.GetPropertyAsFloat(Property.ROTATION_ANGLE);
            float?blockMaxHeight            = RetrieveMaxHeight();
            OverflowPropertyValue?overflowY = (null == blockMaxHeight || blockMaxHeight > parentBBox.GetHeight()) &&
                                              !wasParentsHeightClipped ? OverflowPropertyValue.FIT : this.GetProperty <OverflowPropertyValue?>(Property
                                                                                                                                               .OVERFLOW_Y);

            if (rotation != null || IsFixedLayout())
            {
                parentBBox.MoveDown(AbstractRenderer.INF - parentBBox.GetHeight()).SetHeight(AbstractRenderer.INF);
            }
            if (rotation != null && !FloatingHelper.IsRendererFloating(this))
            {
                blockWidth = RotationUtils.RetrieveRotatedLayoutWidth(parentBBox.GetWidth(), this);
            }
            if (marginsCollapsingEnabled)
            {
                marginsCollapseHandler.StartMarginsCollapse(parentBBox);
            }
            Border[]    borders         = GetBorders();
            UnitValue[] paddings        = GetPaddings();
            float       additionalWidth = ApplyBordersPaddingsMargins(parentBBox, borders, paddings);

            ApplyWidth(parentBBox, blockWidth, overflowX);
            wasHeightClipped = ApplyMaxHeight(parentBBox, blockMaxHeight, marginsCollapseHandler, false, wasParentsHeightClipped
                                              , overflowY);
            MinMaxWidth          minMaxWidth  = new MinMaxWidth(additionalWidth);
            AbstractWidthHandler widthHandler = new MaxMaxWidthHandler(minMaxWidth);
            IList <Rectangle>    areas;

            if (isPositioned)
            {
                areas = JavaCollectionsUtil.SingletonList(parentBBox);
            }
            else
            {
                areas = InitElementAreas(new LayoutArea(pageNumber, parentBBox));
            }
            occupiedArea = new LayoutArea(pageNumber, new Rectangle(parentBBox.GetX(), parentBBox.GetY() + parentBBox.
                                                                    GetHeight(), parentBBox.GetWidth(), 0));
            ShrinkOccupiedAreaForAbsolutePosition();
            int       currentAreaPos = 0;
            Rectangle layoutBox      = areas[0].Clone();

            lines = new List <LineRenderer>();
            foreach (IRenderer child in childRenderers)
            {
                notAllKidsAreFloats = notAllKidsAreFloats || !FloatingHelper.IsRendererFloating(child);
                currentRenderer.AddChild(child);
            }
            float             lastYLine                            = layoutBox.GetY() + layoutBox.GetHeight();
            float             previousDescent                      = 0;
            float             lastLineBottomLeadingIndent          = 0;
            bool              onlyOverflowedFloatsLeft             = false;
            IList <IRenderer> inlineFloatsOverflowedToNextPage     = new List <IRenderer>();
            bool              floatOverflowedToNextPageWithNothing = false;
            // rectangles are compared by instances
            ICollection <Rectangle> nonChildFloatingRendererAreas = new HashSet <Rectangle>(floatRendererAreas);

            if (marginsCollapsingEnabled && childRenderers.Count > 0)
            {
                // passing null is sufficient to notify that there is a kid, however we don't care about it and it's margins
                marginsCollapseHandler.StartChildMarginsHandling(null, layoutBox);
            }
            bool includeFloatsInOccupiedArea = BlockFormattingContextUtil.IsRendererCreateBfc(this);

            while (currentRenderer != null)
            {
                currentRenderer.SetProperty(Property.TAB_DEFAULT, this.GetPropertyAsFloat(Property.TAB_DEFAULT));
                currentRenderer.SetProperty(Property.TAB_STOPS, this.GetProperty <Object>(Property.TAB_STOPS));
                float     lineIndent     = anythingPlaced ? 0 : (float)this.GetPropertyAsFloat(Property.FIRST_LINE_INDENT);
                Rectangle childLayoutBox = new Rectangle(layoutBox.GetX(), layoutBox.GetY(), layoutBox.GetWidth(), layoutBox
                                                         .GetHeight());
                currentRenderer.SetProperty(Property.OVERFLOW_X, overflowX);
                currentRenderer.SetProperty(Property.OVERFLOW_Y, overflowY);
                LineLayoutContext lineLayoutContext = new LineLayoutContext(new LayoutArea(pageNumber, childLayoutBox), null
                                                                            , floatRendererAreas, wasHeightClipped || wasParentsHeightClipped).SetTextIndent(lineIndent).SetFloatOverflowedToNextPageWithNothing
                                                          (floatOverflowedToNextPageWithNothing);
                LineLayoutResult result = (LineLayoutResult)((LineRenderer)currentRenderer.SetParent(this)).Layout(lineLayoutContext
                                                                                                                   );
                if (result.GetStatus() == LayoutResult.NOTHING)
                {
                    float?lineShiftUnderFloats = FloatingHelper.CalculateLineShiftUnderFloats(floatRendererAreas, layoutBox);
                    if (lineShiftUnderFloats != null)
                    {
                        layoutBox.DecreaseHeight((float)lineShiftUnderFloats);
                        firstLineInBox = true;
                        continue;
                    }
                    bool allRemainingKidsAreFloats = !currentRenderer.childRenderers.IsEmpty();
                    foreach (IRenderer renderer in currentRenderer.childRenderers)
                    {
                        allRemainingKidsAreFloats = allRemainingKidsAreFloats && FloatingHelper.IsRendererFloating(renderer);
                    }
                    if (allRemainingKidsAreFloats)
                    {
                        onlyOverflowedFloatsLeft = true;
                    }
                }
                floatOverflowedToNextPageWithNothing = lineLayoutContext.IsFloatOverflowedToNextPageWithNothing();
                if (result.GetFloatsOverflowedToNextPage() != null)
                {
                    inlineFloatsOverflowedToNextPage.AddAll(result.GetFloatsOverflowedToNextPage());
                }
                float minChildWidth = 0;
                float maxChildWidth = 0;
                if (result is MinMaxWidthLayoutResult)
                {
                    minChildWidth = ((MinMaxWidthLayoutResult)result).GetMinMaxWidth().GetMinWidth();
                    maxChildWidth = ((MinMaxWidthLayoutResult)result).GetMinMaxWidth().GetMaxWidth();
                }
                widthHandler.UpdateMinChildWidth(minChildWidth);
                widthHandler.UpdateMaxChildWidth(maxChildWidth);
                LineRenderer processedRenderer = null;
                if (result.GetStatus() == LayoutResult.FULL)
                {
                    processedRenderer = currentRenderer;
                }
                else
                {
                    if (result.GetStatus() == LayoutResult.PARTIAL)
                    {
                        processedRenderer = (LineRenderer)result.GetSplitRenderer();
                    }
                }
                if (onlyOverflowedFloatsLeft)
                {
                    // This is done to trick ParagraphRenderer to break rendering and to overflow to the next page.
                    // The `onlyOverflowedFloatsLeft` is set to true only when no other content is left except
                    // overflowed floating elements.
                    processedRenderer = null;
                }
                TextAlignment?textAlignment = (TextAlignment?)this.GetProperty <TextAlignment?>(Property.TEXT_ALIGNMENT, TextAlignment
                                                                                                .LEFT);
                ApplyTextAlignment(textAlignment, result, processedRenderer, layoutBox, floatRendererAreas, onlyOverflowedFloatsLeft
                                   , lineIndent);
                Leading leading = RenderingMode.HTML_MODE.Equals(this.GetProperty <RenderingMode?>(Property.RENDERING_MODE)
                                                                 ) ? null : this.GetProperty <Leading>(Property.LEADING);
                // could be false if e.g. line contains only floats
                bool lineHasContent = processedRenderer != null && processedRenderer.GetOccupiedArea().GetBBox().GetHeight
                                          () > 0;
                bool  isFit  = processedRenderer != null;
                float deltaY = 0;
                if (isFit && !RenderingMode.HTML_MODE.Equals(this.GetProperty <RenderingMode?>(Property.RENDERING_MODE)))
                {
                    if (lineHasContent)
                    {
                        float indentFromLastLine = previousDescent - lastLineBottomLeadingIndent - (leading != null ? processedRenderer
                                                                                                    .GetTopLeadingIndent(leading) : 0) - processedRenderer.GetMaxAscent();
                        // TODO this is a workaround. To be refactored
                        if (processedRenderer != null && processedRenderer.ContainsImage())
                        {
                            indentFromLastLine += previousDescent;
                        }
                        deltaY = lastYLine + indentFromLastLine - processedRenderer.GetYLine();
                        lastLineBottomLeadingIndent = leading != null?processedRenderer.GetBottomLeadingIndent(leading) : 0;

                        // TODO this is a workaround. To be refactored
                        if (lastLineBottomLeadingIndent < 0 && processedRenderer.ContainsImage())
                        {
                            lastLineBottomLeadingIndent = 0;
                        }
                    }
                    // for the first and last line in a paragraph, leading is smaller
                    if (firstLineInBox)
                    {
                        deltaY = processedRenderer != null && leading != null ? -processedRenderer.GetTopLeadingIndent(leading) :
                                 0;
                    }
                    isFit = leading == null || processedRenderer.GetOccupiedArea().GetBBox().GetY() + deltaY >= layoutBox.GetY
                                ();
                }
                if (!isFit && (null == processedRenderer || IsOverflowFit(overflowY)))
                {
                    if (currentAreaPos + 1 < areas.Count)
                    {
                        layoutBox      = areas[++currentAreaPos].Clone();
                        lastYLine      = layoutBox.GetY() + layoutBox.GetHeight();
                        firstLineInBox = true;
                    }
                    else
                    {
                        bool keepTogether = IsKeepTogether();
                        if (keepTogether)
                        {
                            floatRendererAreas.RetainAll(nonChildFloatingRendererAreas);
                            return(new MinMaxWidthLayoutResult(LayoutResult.NOTHING, null, null, this, null == result.GetCauseOfNothing
                                                                   () ? this : result.GetCauseOfNothing()));
                        }
                        else
                        {
                            if (marginsCollapsingEnabled)
                            {
                                if (anythingPlaced && notAllKidsAreFloats)
                                {
                                    marginsCollapseHandler.EndChildMarginsHandling(layoutBox);
                                }
                            }
                            // On page split, if not only overflowed floats left, content will be drawn on next page, i.e. under all floats on this page
                            bool includeFloatsInOccupiedAreaOnSplit = !onlyOverflowedFloatsLeft || includeFloatsInOccupiedArea;
                            if (includeFloatsInOccupiedAreaOnSplit)
                            {
                                FloatingHelper.IncludeChildFloatsInOccupiedArea(floatRendererAreas, this, nonChildFloatingRendererAreas);
                                FixOccupiedAreaIfOverflowedX(overflowX, layoutBox);
                            }
                            if (marginsCollapsingEnabled)
                            {
                                marginsCollapseHandler.EndMarginsCollapse(layoutBox);
                            }
                            bool minHeightOverflowed = false;
                            if (!includeFloatsInOccupiedAreaOnSplit)
                            {
                                AbstractRenderer minHeightOverflow = ApplyMinHeight(overflowY, layoutBox);
                                minHeightOverflowed = minHeightOverflow != null;
                                ApplyVerticalAlignment();
                            }
                            iText.Layout.Renderer.ParagraphRenderer[] split = Split();
                            split[0].lines = lines;
                            foreach (LineRenderer line in lines)
                            {
                                split[0].childRenderers.AddAll(line.GetChildRenderers());
                            }
                            split[1].childRenderers.AddAll(inlineFloatsOverflowedToNextPage);
                            if (processedRenderer != null)
                            {
                                split[1].childRenderers.AddAll(processedRenderer.GetChildRenderers());
                            }
                            if (result.GetOverflowRenderer() != null)
                            {
                                split[1].childRenderers.AddAll(result.GetOverflowRenderer().GetChildRenderers());
                            }
                            if (onlyOverflowedFloatsLeft && !includeFloatsInOccupiedArea && !minHeightOverflowed)
                            {
                                FloatingHelper.RemoveParentArtifactsOnPageSplitIfOnlyFloatsOverflow(split[1]);
                            }
                            float usedHeight = occupiedArea.GetBBox().GetHeight();
                            if (!includeFloatsInOccupiedAreaOnSplit)
                            {
                                Rectangle commonRectangle = Rectangle.GetCommonRectangle(layoutBox, occupiedArea.GetBBox());
                                usedHeight = commonRectangle.GetHeight();
                            }
                            UpdateHeightsOnSplit(usedHeight, wasHeightClipped, this, split[1], includeFloatsInOccupiedAreaOnSplit);
                            CorrectFixedLayout(layoutBox);
                            ApplyPaddings(occupiedArea.GetBBox(), paddings, true);
                            ApplyBorderBox(occupiedArea.GetBBox(), borders, true);
                            ApplyMargins(occupiedArea.GetBBox(), true);
                            ApplyAbsolutePositionIfNeeded(layoutContext);
                            LayoutArea editedArea = FloatingHelper.AdjustResultOccupiedAreaForFloatAndClear(this, layoutContext.GetFloatRendererAreas
                                                                                                                (), layoutContext.GetArea().GetBBox(), clearHeightCorrection, marginsCollapsingEnabled);
                            if (wasHeightClipped)
                            {
                                return(new MinMaxWidthLayoutResult(LayoutResult.FULL, editedArea, split[0], null).SetMinMaxWidth(minMaxWidth
                                                                                                                                 ));
                            }
                            else
                            {
                                if (anythingPlaced)
                                {
                                    return(new MinMaxWidthLayoutResult(LayoutResult.PARTIAL, editedArea, split[0], split[1]).SetMinMaxWidth(minMaxWidth
                                                                                                                                            ));
                                }
                                else
                                {
                                    if (true.Equals(GetPropertyAsBoolean(Property.FORCED_PLACEMENT)))
                                    {
                                        occupiedArea.SetBBox(Rectangle.GetCommonRectangle(occupiedArea.GetBBox(), currentRenderer.GetOccupiedArea(
                                                                                              ).GetBBox()));
                                        FixOccupiedAreaIfOverflowedX(overflowX, layoutBox);
                                        parent.SetProperty(Property.FULL, true);
                                        lines.Add(currentRenderer);
                                        // Force placement of children we have and do not force placement of the others
                                        if (LayoutResult.PARTIAL == result.GetStatus())
                                        {
                                            IRenderer childNotRendered = result.GetCauseOfNothing();
                                            int       firstNotRendered = currentRenderer.childRenderers.IndexOf(childNotRendered);
                                            currentRenderer.childRenderers.RetainAll(currentRenderer.childRenderers.SubList(0, firstNotRendered));
                                            split[1].childRenderers.RemoveAll(split[1].childRenderers.SubList(0, firstNotRendered));
                                            return(new MinMaxWidthLayoutResult(LayoutResult.PARTIAL, editedArea, this, split[1], null).SetMinMaxWidth(
                                                       minMaxWidth));
                                        }
                                        else
                                        {
                                            return(new MinMaxWidthLayoutResult(LayoutResult.FULL, editedArea, null, null, this).SetMinMaxWidth(minMaxWidth
                                                                                                                                               ));
                                        }
                                    }
                                    else
                                    {
                                        floatRendererAreas.RetainAll(nonChildFloatingRendererAreas);
                                        return(new MinMaxWidthLayoutResult(LayoutResult.NOTHING, null, null, this, null == result.GetCauseOfNothing
                                                                               () ? this : result.GetCauseOfNothing()));
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (leading != null)
                    {
                        processedRenderer.ApplyLeading(deltaY);
                        if (lineHasContent)
                        {
                            lastYLine = processedRenderer.GetYLine();
                        }
                    }
                    if (lineHasContent)
                    {
                        occupiedArea.SetBBox(Rectangle.GetCommonRectangle(occupiedArea.GetBBox(), processedRenderer.GetOccupiedArea
                                                                              ().GetBBox()));
                        FixOccupiedAreaIfOverflowedX(overflowX, layoutBox);
                    }
                    firstLineInBox = false;
                    layoutBox.SetHeight(processedRenderer.GetOccupiedArea().GetBBox().GetY() - layoutBox.GetY());
                    lines.Add(processedRenderer);
                    anythingPlaced  = true;
                    currentRenderer = (LineRenderer)result.GetOverflowRenderer();
                    previousDescent = processedRenderer.GetMaxDescent();
                    if (!inlineFloatsOverflowedToNextPage.IsEmpty() && result.GetOverflowRenderer() == null)
                    {
                        onlyOverflowedFloatsLeft = true;
                        // dummy renderer to trick paragraph renderer to continue kids loop
                        currentRenderer = new LineRenderer();
                    }
                }
            }
            if (!RenderingMode.HTML_MODE.Equals(this.GetProperty <RenderingMode?>(Property.RENDERING_MODE)))
            {
                float moveDown = lastLineBottomLeadingIndent;
                if (IsOverflowFit(overflowY) && moveDown > occupiedArea.GetBBox().GetY() - layoutBox.GetY())
                {
                    moveDown = occupiedArea.GetBBox().GetY() - layoutBox.GetY();
                }
                occupiedArea.GetBBox().MoveDown(moveDown);
                occupiedArea.GetBBox().SetHeight(occupiedArea.GetBBox().GetHeight() + moveDown);
            }
            if (marginsCollapsingEnabled)
            {
                if (childRenderers.Count > 0 && notAllKidsAreFloats)
                {
                    marginsCollapseHandler.EndChildMarginsHandling(layoutBox);
                }
            }
            if (includeFloatsInOccupiedArea)
            {
                FloatingHelper.IncludeChildFloatsInOccupiedArea(floatRendererAreas, this, nonChildFloatingRendererAreas);
                FixOccupiedAreaIfOverflowedX(overflowX, layoutBox);
            }
            if (wasHeightClipped)
            {
                FixOccupiedAreaIfOverflowedY(overflowY, layoutBox);
            }
            if (marginsCollapsingEnabled)
            {
                marginsCollapseHandler.EndMarginsCollapse(layoutBox);
            }
            AbstractRenderer overflowRenderer = ApplyMinHeight(overflowY, layoutBox);

            if (overflowRenderer != null && IsKeepTogether())
            {
                floatRendererAreas.RetainAll(nonChildFloatingRendererAreas);
                return(new LayoutResult(LayoutResult.NOTHING, null, null, this, this));
            }
            CorrectFixedLayout(layoutBox);
            ApplyPaddings(occupiedArea.GetBBox(), paddings, true);
            ApplyBorderBox(occupiedArea.GetBBox(), borders, true);
            ApplyMargins(occupiedArea.GetBBox(), true);
            ApplyAbsolutePositionIfNeeded(layoutContext);
            if (rotation != null)
            {
                ApplyRotationLayout(layoutContext.GetArea().GetBBox().Clone());
                if (IsNotFittingLayoutArea(layoutContext.GetArea()))
                {
                    if (IsNotFittingWidth(layoutContext.GetArea()) && !IsNotFittingHeight(layoutContext.GetArea()))
                    {
                        LogManager.GetLogger(GetType()).Warn(MessageFormatUtil.Format(iText.IO.LogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA
                                                                                      , "It fits by height so it will be forced placed"));
                    }
                    else
                    {
                        if (!true.Equals(GetPropertyAsBoolean(Property.FORCED_PLACEMENT)))
                        {
                            floatRendererAreas.RetainAll(nonChildFloatingRendererAreas);
                            return(new MinMaxWidthLayoutResult(LayoutResult.NOTHING, null, null, this, this));
                        }
                    }
                }
            }
            ApplyVerticalAlignment();
            FloatingHelper.RemoveFloatsAboveRendererBottom(floatRendererAreas, this);
            LayoutArea editedArea_1 = FloatingHelper.AdjustResultOccupiedAreaForFloatAndClear(this, layoutContext.GetFloatRendererAreas
                                                                                                  (), layoutContext.GetArea().GetBBox(), clearHeightCorrection, marginsCollapsingEnabled);

            if (null == overflowRenderer)
            {
                return(new MinMaxWidthLayoutResult(LayoutResult.FULL, editedArea_1, null, null, null).SetMinMaxWidth(minMaxWidth
                                                                                                                     ));
            }
            else
            {
                return(new MinMaxWidthLayoutResult(LayoutResult.PARTIAL, editedArea_1, this, overflowRenderer, null).SetMinMaxWidth
                           (minMaxWidth));
            }
        }
Beispiel #25
0
        private void PopulateSignatureNames()
        {
            if (acroForm == null)
            {
                return;
            }
            IList <Object[]> sorter = new List <Object[]>();

            foreach (KeyValuePair <String, PdfFormField> entry in acroForm.GetFormFields())
            {
                PdfFormField  field  = entry.Value;
                PdfDictionary merged = field.GetPdfObject();
                if (!PdfName.Sig.Equals(merged.Get(PdfName.FT)))
                {
                    continue;
                }
                PdfDictionary v = merged.GetAsDictionary(PdfName.V);
                if (v == null)
                {
                    continue;
                }
                PdfString contents = v.GetAsString(PdfName.Contents);
                if (contents == null)
                {
                    continue;
                }
                else
                {
                    contents.MarkAsUnencryptedObject();
                }
                PdfArray ro = v.GetAsArray(PdfName.ByteRange);
                if (ro == null)
                {
                    continue;
                }
                int rangeSize = ro.Size();
                if (rangeSize < 2)
                {
                    continue;
                }
                int length = ro.GetAsNumber(rangeSize - 1).IntValue() + ro.GetAsNumber(rangeSize - 2).IntValue();
                sorter.Add(new Object[] { entry.Key, new int[] { length, 0 } });
            }
            JavaCollectionsUtil.Sort(sorter, new SignatureUtil.SorterComparator());
            if (sorter.Count > 0)
            {
                try {
                    if (((int[])sorter[sorter.Count - 1][1])[0] == document.GetReader().GetFileLength())
                    {
                        totalRevisions = sorter.Count;
                    }
                    else
                    {
                        totalRevisions = sorter.Count + 1;
                    }
                }
                catch (System.IO.IOException) {
                }
                // TODO: add exception handling (at least some logger)
                for (int k = 0; k < sorter.Count; ++k)
                {
                    Object[] objs = sorter[k];
                    String   name = (String)objs[0];
                    int[]    p    = (int[])objs[1];
                    p[1] = k + 1;
                    sigNames.Put(name, p);
                    orderedSignatureNames.Add(name);
                }
            }
        }
Beispiel #26
0
 public virtual IList <TagTreePointer> GetRefsList()
 {
     return(JavaCollectionsUtil.EmptyList <TagTreePointer>());
 }
Beispiel #27
0
 /// <summary>Get this node's children.</summary>
 /// <remarks>
 /// Get this node's children. Presented as an unmodifiable list: new children can not be added, but the child nodes
 /// themselves can be manipulated.
 /// </remarks>
 /// <returns>list of children. If no children, returns an empty list.</returns>
 public virtual IList <iText.StyledXmlParser.Jsoup.Nodes.Node> ChildNodes()
 {
     return(JavaCollectionsUtil.UnmodifiableList(childNodes));
 }
 public virtual ICollection <EventType> GetSupportedEvents()
 {
     return(new LinkedHashSet <EventType>(JavaCollectionsUtil.SingletonList(EventType.RENDER_TEXT)));
 }
Beispiel #29
0
        public override LayoutResult Layout(LayoutContext layoutContext)
        {
            int       pageNumber   = layoutContext.GetArea().GetPageNumber();
            bool      isPositioned = IsPositioned();
            Rectangle parentBBox   = layoutContext.GetArea().GetBBox().Clone();

            if (this.GetProperty <float?>(Property.ROTATION_ANGLE) != null || isPositioned)
            {
                parentBBox.MoveDown(AbstractRenderer.INF - parentBBox.GetHeight()).SetHeight(AbstractRenderer.INF);
            }
            float?blockHeight = RetrieveHeight();

            if (!IsFixedLayout() && blockHeight != null && blockHeight > parentBBox.GetHeight() && !true.Equals(GetPropertyAsBoolean
                                                                                                                    (Property.FORCED_PLACEMENT)))
            {
                return(new LayoutResult(LayoutResult.NOTHING, null, null, this, this));
            }
            float[] margins = GetMargins();
            ApplyMargins(parentBBox, margins, false);
            Border[] borders = GetBorders();
            ApplyBorderBox(parentBBox, borders, false);
            if (isPositioned)
            {
                float x         = (float)this.GetPropertyAsFloat(Property.X);
                float relativeX = IsFixedLayout() ? 0 : parentBBox.GetX();
                parentBBox.SetX(relativeX + x);
            }
            float?blockWidth = RetrieveWidth(parentBBox.GetWidth());

            if (blockWidth != null && (blockWidth < parentBBox.GetWidth() || isPositioned))
            {
                parentBBox.SetWidth((float)blockWidth);
            }
            float[] paddings = GetPaddings();
            ApplyPaddings(parentBBox, paddings, false);
            IList <Rectangle> areas;

            if (isPositioned)
            {
                areas = JavaCollectionsUtil.SingletonList(parentBBox);
            }
            else
            {
                areas = InitElementAreas(new LayoutArea(pageNumber, parentBBox));
            }
            occupiedArea = new LayoutArea(pageNumber, new Rectangle(parentBBox.GetX(), parentBBox.GetY() + parentBBox.
                                                                    GetHeight(), parentBBox.GetWidth(), 0));
            int       currentAreaPos = 0;
            Rectangle layoutBox      = areas[0].Clone();
            // the first renderer (one of childRenderers or their children) to produce LayoutResult.NOTHING
            IRenderer causeOfNothing = null;
            bool      anythingPlaced = false;

            for (int childPos = 0; childPos < childRenderers.Count; childPos++)
            {
                IRenderer    childRenderer = childRenderers[childPos];
                LayoutResult result;
                childRenderer.SetParent(this);
                while ((result = childRenderer.SetParent(this).Layout(new LayoutContext(new LayoutArea(pageNumber, layoutBox
                                                                                                       )))).GetStatus() != LayoutResult.FULL)
                {
                    if (result.GetOccupiedArea() != null)
                    {
                        occupiedArea.SetBBox(Rectangle.GetCommonRectangle(occupiedArea.GetBBox(), result.GetOccupiedArea().GetBBox
                                                                              ()));
                        layoutBox.SetHeight(layoutBox.GetHeight() - result.GetOccupiedArea().GetBBox().GetHeight());
                    }
                    if (childRenderer.GetOccupiedArea() != null)
                    {
                        AlignChildHorizontally(childRenderer, layoutBox.GetWidth());
                    }
                    // Save the first renderer to produce LayoutResult.NOTHING
                    if (null == causeOfNothing && null != result.GetCauseOfNothing())
                    {
                        causeOfNothing = result.GetCauseOfNothing();
                    }
                    // have more areas
                    if (currentAreaPos + 1 < areas.Count)
                    {
                        if (result.GetStatus() == LayoutResult.PARTIAL)
                        {
                            childRenderers[childPos] = result.GetSplitRenderer();
                            // TODO linkedList would make it faster
                            childRenderers.Add(childPos + 1, result.GetOverflowRenderer());
                        }
                        else
                        {
                            childRenderers[childPos] = result.GetOverflowRenderer();
                            childPos--;
                        }
                        layoutBox = areas[++currentAreaPos].Clone();
                        break;
                    }
                    else
                    {
                        if (result.GetStatus() == LayoutResult.PARTIAL)
                        {
                            layoutBox.SetHeight(layoutBox.GetHeight() - result.GetOccupiedArea().GetBBox().GetHeight());
                            if (currentAreaPos + 1 == areas.Count)
                            {
                                AbstractRenderer splitRenderer = CreateSplitRenderer(LayoutResult.PARTIAL);
                                splitRenderer.childRenderers = new List <IRenderer>(childRenderers.SubList(0, childPos));
                                splitRenderer.childRenderers.Add(result.GetSplitRenderer());
                                splitRenderer.occupiedArea = occupiedArea;
                                AbstractRenderer overflowRenderer = CreateOverflowRenderer(LayoutResult.PARTIAL);
                                // Apply forced placement only on split renderer
                                overflowRenderer.DeleteOwnProperty(Property.FORCED_PLACEMENT);
                                IList <IRenderer> overflowRendererChildren = new List <IRenderer>();
                                overflowRendererChildren.Add(result.GetOverflowRenderer());
                                overflowRendererChildren.AddAll(childRenderers.SubList(childPos + 1, childRenderers.Count));
                                overflowRenderer.childRenderers = overflowRendererChildren;
                                ApplyPaddings(occupiedArea.GetBBox(), paddings, true);
                                ApplyBorderBox(occupiedArea.GetBBox(), borders, true);
                                ApplyMargins(occupiedArea.GetBBox(), margins, true);
                                return(new LayoutResult(LayoutResult.PARTIAL, occupiedArea, splitRenderer, overflowRenderer, causeOfNothing
                                                        ));
                            }
                            else
                            {
                                childRenderers[childPos] = result.GetSplitRenderer();
                                childRenderers.Add(childPos + 1, result.GetOverflowRenderer());
                                layoutBox = areas[++currentAreaPos].Clone();
                                break;
                            }
                        }
                        else
                        {
                            if (result.GetStatus() == LayoutResult.NOTHING)
                            {
                                bool             keepTogether  = IsKeepTogether();
                                int              layoutResult  = anythingPlaced && !keepTogether ? LayoutResult.PARTIAL : LayoutResult.NOTHING;
                                AbstractRenderer splitRenderer = CreateSplitRenderer(layoutResult);
                                splitRenderer.childRenderers = new List <IRenderer>(childRenderers.SubList(0, childPos));
                                foreach (IRenderer renderer in splitRenderer.childRenderers)
                                {
                                    renderer.SetParent(splitRenderer);
                                }
                                AbstractRenderer  overflowRenderer         = CreateOverflowRenderer(layoutResult);
                                IList <IRenderer> overflowRendererChildren = new List <IRenderer>();
                                overflowRendererChildren.Add(result.GetOverflowRenderer());
                                overflowRendererChildren.AddAll(childRenderers.SubList(childPos + 1, childRenderers.Count));
                                overflowRenderer.childRenderers = overflowRendererChildren;
                                if (keepTogether)
                                {
                                    splitRenderer = null;
                                    overflowRenderer.childRenderers.Clear();
                                    overflowRenderer.childRenderers = new List <IRenderer>(childRenderers);
                                }
                                ApplyPaddings(occupiedArea.GetBBox(), paddings, true);
                                ApplyBorderBox(occupiedArea.GetBBox(), borders, true);
                                ApplyMargins(occupiedArea.GetBBox(), margins, true);
                                if (true.Equals(GetPropertyAsBoolean(Property.FORCED_PLACEMENT)))
                                {
                                    return(new LayoutResult(LayoutResult.FULL, occupiedArea, null, null));
                                }
                                else
                                {
                                    return(new LayoutResult(layoutResult, occupiedArea, splitRenderer, overflowRenderer, LayoutResult.NOTHING
                                                            == layoutResult ? result.GetCauseOfNothing() : null));
                                }
                            }
                        }
                    }
                }
                anythingPlaced = true;
                occupiedArea.SetBBox(Rectangle.GetCommonRectangle(occupiedArea.GetBBox(), result.GetOccupiedArea().GetBBox
                                                                      ()));
                if (result.GetStatus() == LayoutResult.FULL)
                {
                    layoutBox.SetHeight(layoutBox.GetHeight() - result.GetOccupiedArea().GetBBox().GetHeight());
                    if (childRenderer.GetOccupiedArea() != null)
                    {
                        AlignChildHorizontally(childRenderer, layoutBox.GetWidth());
                    }
                }
                // Save the first renderer to produce LayoutResult.NOTHING
                if (null == causeOfNothing && null != result.GetCauseOfNothing())
                {
                    causeOfNothing = result.GetCauseOfNothing();
                }
            }
            ApplyPaddings(occupiedArea.GetBBox(), paddings, true);
            if (blockHeight != null && blockHeight > occupiedArea.GetBBox().GetHeight())
            {
                occupiedArea.GetBBox().MoveDown((float)blockHeight - occupiedArea.GetBBox().GetHeight()).SetHeight((float)
                                                                                                                   blockHeight);
            }
            if (isPositioned)
            {
                float y         = (float)this.GetPropertyAsFloat(Property.Y);
                float relativeY = IsFixedLayout() ? 0 : layoutBox.GetY();
                Move(0, relativeY + y - occupiedArea.GetBBox().GetY());
            }
            ApplyBorderBox(occupiedArea.GetBBox(), borders, true);
            ApplyMargins(occupiedArea.GetBBox(), margins, true);
            if (this.GetProperty <float?>(Property.ROTATION_ANGLE) != null)
            {
                ApplyRotationLayout(layoutContext.GetArea().GetBBox().Clone());
                if (IsNotFittingLayoutArea(layoutContext.GetArea()))
                {
                    if (!true.Equals(GetPropertyAsBoolean(Property.FORCED_PLACEMENT)))
                    {
                        return(new LayoutResult(LayoutResult.NOTHING, occupiedArea, null, this, this));
                    }
                }
            }
            ApplyVerticalAlignment();
            return(new LayoutResult(LayoutResult.FULL, occupiedArea, null, null, causeOfNothing));
        }
Beispiel #30
0
 public override void Draw(DrawContext drawContext)
 {
     if (occupiedArea == null)
     {
         ILog logger = LogManager.GetLogger(typeof(iText.Layout.Renderer.ListItemRenderer));
         logger.Error(MessageFormatUtil.Format(iText.IO.LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED,
                                               "Drawing won't be performed."));
         return;
     }
     if (drawContext.IsTaggingEnabled())
     {
         LayoutTaggingHelper taggingHelper = this.GetProperty <LayoutTaggingHelper>(Property.TAGGING_HELPER);
         if (taggingHelper != null)
         {
             if (symbolRenderer != null)
             {
                 LayoutTaggingHelper.AddTreeHints(taggingHelper, symbolRenderer);
             }
             if (taggingHelper.IsArtifact(this))
             {
                 taggingHelper.MarkArtifactHint(symbolRenderer);
             }
             else
             {
                 TaggingHintKey hintKey    = LayoutTaggingHelper.GetHintKey(this);
                 TaggingHintKey parentHint = taggingHelper.GetAccessibleParentHint(hintKey);
                 if (parentHint != null && !(StandardRoles.LI.Equals(parentHint.GetAccessibleElement().GetAccessibilityProperties
                                                                         ().GetRole())))
                 {
                     TaggingDummyElement    listItemIntermediate = new TaggingDummyElement(StandardRoles.LI);
                     IList <TaggingHintKey> intermediateKid      = JavaCollectionsUtil.SingletonList <TaggingHintKey>(LayoutTaggingHelper
                                                                                                                      .GetOrCreateHintKey(listItemIntermediate));
                     taggingHelper.ReplaceKidHint(hintKey, intermediateKid);
                     if (symbolRenderer != null)
                     {
                         taggingHelper.AddKidsHint(listItemIntermediate, JavaCollectionsUtil.SingletonList <IRenderer>(symbolRenderer
                                                                                                                       ));
                     }
                     taggingHelper.AddKidsHint(listItemIntermediate, JavaCollectionsUtil.SingletonList <IRenderer>(this));
                 }
             }
         }
     }
     base.Draw(drawContext);
     // It will be null in case of overflow (only the "split" part will contain symbol renderer.
     if (symbolRenderer != null && !symbolAddedInside)
     {
         bool isRtl = BaseDirection.RIGHT_TO_LEFT.Equals(this.GetProperty <BaseDirection?>(Property.BASE_DIRECTION));
         symbolRenderer.SetParent(this);
         float x = isRtl ? occupiedArea.GetBBox().GetRight() : occupiedArea.GetBBox().GetLeft();
         ListSymbolPosition symbolPosition = (ListSymbolPosition)ListRenderer.GetListItemOrListProperty(this, parent
                                                                                                        , Property.LIST_SYMBOL_POSITION);
         if (symbolPosition != ListSymbolPosition.DEFAULT)
         {
             float?symbolIndent = this.GetPropertyAsFloat(Property.LIST_SYMBOL_INDENT);
             if (isRtl)
             {
                 x += (symbolAreaWidth + (float)(symbolIndent == null ? 0 : symbolIndent));
             }
             else
             {
                 x -= (symbolAreaWidth + (float)(symbolIndent == null ? 0 : symbolIndent));
             }
             if (symbolPosition == ListSymbolPosition.OUTSIDE)
             {
                 if (isRtl)
                 {
                     UnitValue marginRightUV = this.GetPropertyAsUnitValue(Property.MARGIN_RIGHT);
                     if (!marginRightUV.IsPointValue())
                     {
                         ILog logger = LogManager.GetLogger(typeof(iText.Layout.Renderer.ListItemRenderer));
                         logger.Error(MessageFormatUtil.Format(iText.IO.LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property
                                                               .MARGIN_RIGHT));
                     }
                     x -= marginRightUV.GetValue();
                 }
                 else
                 {
                     UnitValue marginLeftUV = this.GetPropertyAsUnitValue(Property.MARGIN_LEFT);
                     if (!marginLeftUV.IsPointValue())
                     {
                         ILog logger = LogManager.GetLogger(typeof(iText.Layout.Renderer.ListItemRenderer));
                         logger.Error(MessageFormatUtil.Format(iText.IO.LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property
                                                               .MARGIN_LEFT));
                     }
                     x += marginLeftUV.GetValue();
                 }
             }
         }
         ApplyMargins(occupiedArea.GetBBox(), false);
         ApplyBorderBox(occupiedArea.GetBBox(), false);
         if (childRenderers.Count > 0)
         {
             float?yLine = null;
             for (int i = 0; i < childRenderers.Count; i++)
             {
                 if (childRenderers[i].GetOccupiedArea().GetBBox().GetHeight() > 0)
                 {
                     yLine = ((AbstractRenderer)childRenderers[i]).GetFirstYLineRecursively();
                     if (yLine != null)
                     {
                         break;
                     }
                 }
             }
             if (yLine != null)
             {
                 if (symbolRenderer is LineRenderer)
                 {
                     symbolRenderer.Move(0, (float)yLine - ((LineRenderer)symbolRenderer).GetYLine());
                 }
                 else
                 {
                     symbolRenderer.Move(0, (float)yLine - symbolRenderer.GetOccupiedArea().GetBBox().GetY());
                 }
             }
             else
             {
                 symbolRenderer.Move(0, occupiedArea.GetBBox().GetY() + occupiedArea.GetBBox().GetHeight() - (symbolRenderer
                                                                                                              .GetOccupiedArea().GetBBox().GetY() + symbolRenderer.GetOccupiedArea().GetBBox().GetHeight()));
             }
         }
         else
         {
             if (symbolRenderer is TextRenderer)
             {
                 ((TextRenderer)symbolRenderer).MoveYLineTo(occupiedArea.GetBBox().GetY() + occupiedArea.GetBBox().GetHeight
                                                                () - CalculateAscenderDescender()[0]);
             }
             else
             {
                 symbolRenderer.Move(0, occupiedArea.GetBBox().GetY() + occupiedArea.GetBBox().GetHeight() - symbolRenderer
                                     .GetOccupiedArea().GetBBox().GetHeight() - symbolRenderer.GetOccupiedArea().GetBBox().GetY());
             }
         }
         ApplyBorderBox(occupiedArea.GetBBox(), true);
         ApplyMargins(occupiedArea.GetBBox(), true);
         ListSymbolAlignment listSymbolAlignment = (ListSymbolAlignment)parent.GetProperty <ListSymbolAlignment?>(Property
                                                                                                                  .LIST_SYMBOL_ALIGNMENT, isRtl ? ListSymbolAlignment.LEFT : ListSymbolAlignment.RIGHT);
         float dxPosition = x - symbolRenderer.GetOccupiedArea().GetBBox().GetX();
         if (listSymbolAlignment == ListSymbolAlignment.RIGHT)
         {
             if (!isRtl)
             {
                 dxPosition += symbolAreaWidth - symbolRenderer.GetOccupiedArea().GetBBox().GetWidth();
             }
         }
         else
         {
             if (listSymbolAlignment == ListSymbolAlignment.LEFT)
             {
                 if (isRtl)
                 {
                     dxPosition -= (symbolAreaWidth - symbolRenderer.GetOccupiedArea().GetBBox().GetWidth());
                 }
             }
         }
         if (symbolRenderer is LineRenderer)
         {
             if (isRtl)
             {
                 symbolRenderer.Move(dxPosition - symbolRenderer.GetOccupiedArea().GetBBox().GetWidth(), 0);
             }
             else
             {
                 symbolRenderer.Move(dxPosition, 0);
             }
         }
         else
         {
             symbolRenderer.Move(dxPosition, 0);
         }
         if (symbolRenderer.GetOccupiedArea().GetBBox().GetRight() > parent.GetOccupiedArea().GetBBox().GetLeft())
         {
             BeginElementOpacityApplying(drawContext);
             symbolRenderer.Draw(drawContext);
             EndElementOpacityApplying(drawContext);
         }
     }
 }