当前位置: 首页>>代码示例>>C#>>正文


C# IWorkerContext.Get方法代码示例

本文整理汇总了C#中IWorkerContext.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IWorkerContext.Get方法的具体用法?C# IWorkerContext.Get怎么用?C# IWorkerContext.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IWorkerContext的用法示例。


在下文中一共展示了IWorkerContext.Get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

 public override IList<IElement> Start(IWorkerContext ctx, Tag tag)
 {
     List<IElement> l = new List<IElement>(1);
     try
     {
         IDictionary<String, String> css = tag.CSS;
         if (css.ContainsKey(CSS.Property.BACKGROUND_COLOR))
         {
             Type type = typeof(PdfWriterPipeline);
             MapContext pipeline = (MapContext)ctx.Get(type.FullName);
             if (pipeline != null)
             {
                 Document document = (Document)pipeline[PdfWriterPipeline.DOCUMENT];
                 if (document != null)
                 {
                     Rectangle rectangle = new Rectangle(document.Left, document.Bottom, document.Right, document.Top, document.PageSize.Rotation);
                     rectangle.BackgroundColor = HtmlUtilities.DecodeColor(css[CSS.Property.BACKGROUND_COLOR]);
                     PdfBody body = new PdfBody(rectangle);
                     l.Add(body);
                 }
             }
         }
     }
     catch (NoCustomContextException e)
     {}
     
     return l;
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:28,代码来源:Body.cs

示例2: Open

        /*
         * (non-Javadoc)
         *
         * @see
         * com.itextpdf.tool.xml.pipeline.AbstractPipeline#open(com.itextpdf.tool
         * .xml.Tag, com.itextpdf.tool.xml.pipeline.ProcessObject)
         */
        public override IPipeline Open(IWorkerContext context, Tag t, ProcessObject po)
        {
            try {
                String tagName = t.Name;
                if (tag.Equals(tagName)) {
                    MapContext cc;
                    cc = (MapContext) context.Get(typeof(PdfWriterPipeline).FullName);
                    Document d = new Document(pagesize);
                    try {
                        Stream os = fm.GetStream();
                        cc[PdfWriterPipeline.DOCUMENT] = d;
                        cc[PdfWriterPipeline.WRITER] = PdfWriter.GetInstance(d, os);
                    } catch (IOException e) {
                        throw new PipelineException(e);
                    } catch (DocumentException e) {
                        throw new PipelineException(e);
                    }

                }
                if (Util.EqualsIgnoreCase(t.Name, opentag)) {
                    MapContext cc;
                    cc = (MapContext) context.Get(typeof(PdfWriterPipeline).FullName);
                    Document d = (Document) cc[PdfWriterPipeline.DOCUMENT];
                    CssUtils cssUtils = CssUtils.GetInstance();
                    float pageWidth = d.PageSize.Width;
                    float marginLeft = 0;
                    float marginRight = 0;
                    float marginTop = 0;
                    float marginBottom = 0;
                    IDictionary<String, String> css = t.CSS;
                    foreach (KeyValuePair<String, String> entry in css) {
                        String key = entry.Key;
                        String value = entry.Value;
                        if (Util.EqualsIgnoreCase(key, CSS.Property.MARGIN_LEFT)) {
                            marginLeft = cssUtils.ParseValueToPt(value, pageWidth);
                        } else if (Util.EqualsIgnoreCase(key, CSS.Property.MARGIN_RIGHT)) {
                            marginRight = cssUtils.ParseValueToPt(value, pageWidth);
                        } else if (Util.EqualsIgnoreCase(key, CSS.Property.MARGIN_TOP)) {
                            marginTop = cssUtils.ParseValueToPt(value, pageWidth);
                        } else if (Util.EqualsIgnoreCase(key, CSS.Property.MARGIN_BOTTOM)) {
                            marginBottom = cssUtils.ParseValueToPt(value, pageWidth);
                        }
                    }
                    d.SetMargins(marginLeft, marginRight, marginTop, marginBottom);
                    d.Open();

                }
            } catch (NoCustomContextException e) {
                throw new PipelineException(LocaleMessages.GetInstance().GetMessage(LocaleMessages.PIPELINE_AUTODOC), e);
            }

            return GetNext();
        }
开发者ID:boecko,项目名称:iTextSharp,代码行数:60,代码来源:AutoDocPipeline.cs

示例3: Close

 /*
  * (non-Javadoc)
  *
  * @see
  * com.itextpdf.tool.xml.pipeline.AbstractPipeline#close(com.itextpdf.tool
  * .xml.Tag, com.itextpdf.tool.xml.pipeline.ProcessObject)
  */
 public override IPipeline Close(IWorkerContext context, Tag t, ProcessObject po)
 {
     String tagName = t.Name;
     if (tag.Equals(tagName)) {
         MapContext cc;
         try {
             cc = (MapContext) context.Get(typeof(PdfWriterPipeline).FullName);
             Document d = (Document) cc[PdfWriterPipeline.DOCUMENT];
             d.Close();
         } catch (NoCustomContextException e) {
             throw new PipelineException("AutoDocPipeline depends on PdfWriterPipeline.", e);
         }
         try {
             HtmlPipelineContext hpc = (HtmlPipelineContext) context.Get(typeof(HtmlPipeline).FullName);
             HtmlPipelineContext clone = (HtmlPipelineContext)hpc.Clone();
             clone.SetPageSize(pagesize);
             ((WorkerContextImpl)context).Put(typeof(HtmlPipeline).FullName, clone);
         } catch (NoCustomContextException) {
         }
     }
     return GetNext();
 }
开发者ID:boecko,项目名称:iTextSharp,代码行数:29,代码来源:AutoDocPipeline.cs

示例4: GetHtmlPipelineContext

 /**
  * Utility method that fetches the HtmlPipelineContext used if any and if it
  * uses the default key.
  * @return a HtmlPipelineContext
  * @throws NoCustomContextException if the context of the
  *             {@link HtmlPipelineContext} could not be found.
  */
 public virtual HtmlPipelineContext GetHtmlPipelineContext(IWorkerContext ctx) {
     return (HtmlPipelineContext) ctx.Get(typeof(HtmlPipeline).FullName);
 }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:10,代码来源:AbstractTagProcessor.cs

示例5: GetCSSResolver

 /**
  * Utility method that fetches the CSSResolver from the if any and if it uses the default key.
  *
  * @return CSSResolver
  * @throws NoCustomContextException if the context of the
  *             {@link CssResolverPipeline} could not be found.
  */
 public virtual ICSSResolver GetCSSResolver(IWorkerContext context) {
     return ((ObjectContext<ICSSResolver>)context.Get(typeof(CssResolverPipeline).FullName)).Get();
     //return (ICSSResolver) ((MapContext)ctx.Get(typeof(CssResolverPipeline).FullName))[CssResolverPipeline.CSS_RESOLVER];
 }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:11,代码来源:AbstractTagProcessor.cs

示例6: GetLocalContext

 public virtual ICustomContext GetLocalContext(IWorkerContext context) {
     try {
         ICustomContext cc = context.Get(GetContextKey());
         if (null != cc) {
             return cc;
         }
         throw new PipelineException(String.Format(LocaleMessages.GetInstance().GetMessage(LocaleMessages.OWN_CONTEXT_404), this.GetType().FullName));
     } catch (NoCustomContextException e) {
         throw new PipelineException(String.Format(LocaleMessages.GetInstance().GetMessage(LocaleMessages.OWN_CONTEXT_404), this.GetType().FullName), e);
     }
 }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:11,代码来源:AbstractPipeline.cs


注:本文中的IWorkerContext.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。