Exemple #1
0
 /// <summary>
 /// Constructor which allows injecting a custom
 /// <see cref="ISvgNodeRendererMapper"/>
 /// implementation.
 /// </summary>
 /// <param name="mapper">
 /// the custom mapper implementation - if null, then we fall
 /// back to the
 /// <see cref="DefaultSvgNodeRendererMapper"/>
 /// </param>
 public DefaultSvgNodeRendererFactory(ISvgNodeRendererMapper mapper)
 {
     if (mapper != null)
     {
         rendererMap.AddAll(mapper.GetMapping());
         ignoredTags.AddAll(mapper.GetIgnoredTags());
     }
     else
     {
         ISvgNodeRendererMapper defaultMapper = new DefaultSvgNodeRendererMapper();
         rendererMap.AddAll(defaultMapper.GetMapping());
         ignoredTags.AddAll(defaultMapper.GetIgnoredTags());
     }
 }
        private PageRange GetNextRange(int startPage, int endPage, long size)
        {
            PdfResourceCounter           counter   = new PdfResourceCounter(pdfDocument.GetTrailer());
            IDictionary <int, PdfObject> resources = counter.GetResources();
            long lengthWithoutXref = counter.GetLength(null);
            // initialize with trailer length
            int  currentPage = startPage;
            bool oversized   = false;

            do
            {
                PdfPage page = pdfDocument.GetPage(currentPage++);
                counter            = new PdfResourceCounter(page.GetPdfObject());
                lengthWithoutXref += counter.GetLength(resources);
                resources.AddAll(counter.GetResources());
                if (lengthWithoutXref + XrefLength(resources.Count) > size)
                {
                    oversized = true;
                }
            }while (currentPage <= endPage && !oversized);
            // true if at least the first page to be copied didn't cause the oversize
            if (oversized && (currentPage - 1) != startPage)
            {
                // we shouldn't copy previous page because it caused
                // the oversize and it isn't the first page to be copied
                --currentPage;
            }
            return(new PageRange().AddPageSequence(startPage, currentPage - 1));
        }
 /// <summary>
 /// Constructor, initialises a <see cref="TagInstance"/>
 /// </summary>
 /// <param name="charRange">The range of characters that the tag falls under</param>
 /// <param name="parentDefinition">
 /// The <see cref="ITagDefinition"/> that created this <see cref="ITagInstance"/>
 /// </param>
 /// <param name="rendersToInlineElement">
 /// Whether or not the tag will render to an inline XHTML element (such as a span tag) or not (such as a
 /// blockquote tag).
 /// </param>
 /// <param name="attributes">Any attributes set on the tag (ie. tag metadata)</param>
 protected TagInstance(CharRange charRange, ITagDefinition parentDefinition, bool rendersToInlineElement, IEnumerable <KeyValuePair <string, object> > attributes)
 {
     _CharRange = charRange;
     _RendersToInlineElement = rendersToInlineElement;
     _ParentDefinition       = parentDefinition;
     _Attributes             = new Dictionary <string, object>();
     _Attributes.AddAll(attributes);
     _Attributes = new ReadOnlyDictionary <string, object>(_Attributes);
 }
Exemple #4
0
        public static void SyncByValueWith <TK, TV>(this IDictionary <TK, TV> dict, IDictionary <TK, TV> syncDict)
        {
            //Find new
            var newElements = syncDict.ToList().FindAll(value => !dict.Values.Contains(value.Value)).Select(value => value.Key).ToArray();
            //Find removed
            var removedElements = dict.ToList().FindAll(value => !syncDict.Values.Contains(value.Value)).Select(value => value.Key).ToArray();

            dict.RemoveAll(removedElements);
            dict.AddAll(syncDict.Where(pair => newElements.Contains(pair.Key)));
        }
Exemple #5
0
        public static void SyncByKeyWith <TK, TV>(this IDictionary <TK, TV> dict, IDictionary <TK, TV> syncDict, Action <IDictionary <TK, TV>, TK, TV> overwriteAction)
        {
            //Find removed
            var removedElements = dict.Keys.ToList().FindAll(value => !syncDict.Keys.Contains(value)).ToArray();
            //Find new
            var newElements = syncDict.Keys.ToList().FindAll(value => !dict.Keys.Contains(value)).ToArray();
            //Find already inserted elements
            var alreadyInsertedElements = dict.Keys.Where(syncDict.ContainsKey).ToArray();

            dict.RemoveAll(removedElements);                                     //Remove in sync missed values
            dict.AddAll(syncDict.Where(pair => newElements.Contains(pair.Key))); //Add new values from sync
            //Overwrite inserted elements with new(?) value
            foreach (var alreadyInsertedElement in alreadyInsertedElements)
            {
                overwriteAction(dict, alreadyInsertedElement, syncDict[alreadyInsertedElement]);
            }
        }
        /// <summary>
        /// Used by <see cref="DrillSideways"/>
        /// </summary>
        internal DrillDownQuery(FacetsConfig config, Filter filter, DrillDownQuery other)
        {
            query = new BooleanQuery(true); // disable coord

            BooleanClause[] clauses = other.query.GetClauses();
            if (clauses.Length == other.drillDownDims.Count)
            {
                throw new System.ArgumentException("cannot apply filter unless baseQuery isn't null; pass ConstantScoreQuery instead");
            }
            Debug.Assert(clauses.Length == 1 + other.drillDownDims.Count, clauses.Length + " vs " + (1 + other.drillDownDims.Count));
            drillDownDims.AddAll(other.drillDownDims);
            query.Add(new FilteredQuery(clauses[0].Query, filter), Occur.MUST);
            for (int i = 1; i < clauses.Length; i++)
            {
                query.Add(clauses[i].Query, Occur.MUST);
            }
            this.config = config;
        }
Exemple #7
0
        /* (non-Javadoc)
         * @see com.itextpdf.html2pdf.attach.ITagWorker#processTagChild(com.itextpdf.html2pdf.attach.ITagWorker, com.itextpdf.html2pdf.attach.ProcessorContext)
         */
        public virtual bool ProcessTagChild(ITagWorker childTagWorker, ProcessorContext context)
        {
            IPropertyContainer element = childTagWorker.GetElementResult();

            if (element is ILeafElement)
            {
                FlushInlineHelper();
                spanWrapper.Add((ILeafElement)element);
                ownLeafElements.Add(element);
                return(true);
            }
            else
            {
                if (childTagWorker is iText.Html2pdf.Attach.Impl.Tags.SpanTagWorker)
                {
                    FlushInlineHelper();
                    spanWrapper.Add(((iText.Html2pdf.Attach.Impl.Tags.SpanTagWorker)childTagWorker).spanWrapper);
                    childrenDisplayMap.AddAll(((iText.Html2pdf.Attach.Impl.Tags.SpanTagWorker)childTagWorker).childrenDisplayMap
                                              );
                    return(true);
                }
                else
                {
                    if (childTagWorker.GetElementResult() is IBlockElement)
                    {
                        if (childTagWorker is IDisplayAware)
                        {
                            String display = ((IDisplayAware)childTagWorker).GetDisplay();
                            childrenDisplayMap.Put(childTagWorker.GetElementResult(), display);
                        }
                        FlushInlineHelper();
                        spanWrapper.Add((IBlockElement)childTagWorker.GetElementResult());
                        return(true);
                    }
                }
            }
            return(false);
        }
 /// <summary>Put all tag priority mappings.</summary>
 /// <param name="mappings">the mappings</param>
 /// <returns>the outline handler</returns>
 public virtual OutlineHandler PutAllTagPriorityMappings(IDictionary <String, int?> mappings)
 {
     tagPrioritiesMapping.AddAll(mappings);
     return(this);
 }
Exemple #9
0
 public static void SetAll <TK, TV>(this IDictionary <TK, TV> dict, IDictionary <TK, TV> other)
 {
     dict.Clear();
     dict.AddAll(other);
 }
Exemple #10
0
 public static void SetAll <TK, TV>(this IDictionary <TK, TV> dict, IEnumerable <KeyValuePair <TK, TV> > keyValuePairs)
 {
     dict.Clear();
     dict.AddAll(keyValuePairs);
 }
Exemple #11
0
 public static void SetAll <TK, TV>(this IDictionary <TK, TV> dict, params KeyValuePair <TK, TV>[] keyValuePairs)
 {
     dict.Clear();
     dict.AddAll(keyValuePairs);
 }
 internal virtual void TransferSessionBuffers()
 {
     _bufferedSessionArrays.Clear();
     _bufferedSessionArrays.AddAll(_currentSessionArrays);
     _currentSessionArrays.Clear();
 }
Exemple #13
0
 /// <summary>Creates a new PdfDictionary instance.</summary>
 /// <remarks>
 /// Creates a new PdfDictionary instance. This constructor inserts the content of the specified PdfDictionary
 /// into this PdfDictionary instance.
 /// </remarks>
 /// <param name="dictionary">PdfDictionary containing values to be inserted into PdfDictionary</param>
 public PdfDictionary(iText.Kernel.Pdf.PdfDictionary dictionary)
 {
     map.AddAll(dictionary.map);
 }