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


C# PdfDictionary.GetAsDict方法代码示例

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


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

示例1: ProcessContent

 /**
  * Processes PDF syntax.
  * <b>Note:</b> If you re-use a given {@link PdfContentStreamProcessor}, you must call {@link PdfContentStreamProcessor#reset()}
  * @param contentBytes  the bytes of a content stream
  * @param resources     the resources that come with the content stream
  */
 public void ProcessContent(byte[] contentBytes, PdfDictionary resources){
     this.resources.Push(resources);
     PRTokeniser tokeniser = new PRTokeniser(new RandomAccessFileOrArray(new RandomAccessSourceFactory().CreateSource(contentBytes)));
     PdfContentParser ps = new PdfContentParser(tokeniser);
     List<PdfObject> operands = new List<PdfObject>();
     while (ps.Parse(operands).Count > 0){
         PdfLiteral oper = (PdfLiteral)operands[operands.Count-1];
         if ("BI".Equals(oper.ToString())){
             // we don't call invokeOperator for embedded images - this is one area of the PDF spec that is particularly nasty and inconsistent
             PdfDictionary colorSpaceDic = resources != null ? resources.GetAsDict(PdfName.COLORSPACE) : null;
             HandleInlineImage(InlineImageUtils.ParseInlineImage(ps, colorSpaceDic), colorSpaceDic);
         } else {
             InvokeOperator(oper, operands);
         }
     }
     this.resources.Pop();
 }
开发者ID:Gianluigi,项目名称:dssnet,代码行数:23,代码来源:PdfContentStreamProcessor.cs

示例2: RemoveProperties

 /// <summary>
 /// Removes ocgs from a page resources </summary>
 /// <param name="page">	a page dictionary </param>
 /// <param name="ocgs">	a set of names of OCG layers </param>
 private void RemoveProperties(PdfDictionary page, ICollection<string> ocgs) {
     PdfDictionary resources = page.GetAsDict(PdfName.RESOURCES);
     if (resources == null) {
         return;
     }
     PdfDictionary properties = resources.GetAsDict(PdfName.PROPERTIES);
     if (properties == null) {
         return;
     }
     ICollection<PdfName> names = properties.Keys;
     IList<PdfName> remove = new List<PdfName>();
     foreach (PdfName name in names) {
         PdfDictionary dict = properties.GetAsDict(name);
         if (IsToBeRemoved(dict, ocgs)) {
             remove.Add(name);
         } else {
             RemoveOCGsFromArray(dict, PdfName.OCGS, ocgs);
         }
     }
     foreach (PdfName name in remove) {
         properties.Remove(name);
     }
 }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:27,代码来源:OCGRemover.cs

示例3: Parse

 /// <summary>
 /// Uses the OCGParser on a page </summary>
 /// <param name="parser">	the OCGParser </param>
 /// <param name="page">		the page dictionary of the page that needs to be parsed. </param>
 /// <exception cref="IOException"> </exception>
 private void Parse(OCGParser parser, PdfDictionary page) {
     PRStream stream = (PRStream) page.GetAsStream(PdfName.CONTENTS);
     PdfDictionary resources = page.GetAsDict(PdfName.RESOURCES);
     parser.Parse(stream, resources);
 }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:10,代码来源:OCGRemover.cs

示例4: ParseTag

 /**
  * Searches for a tag in a page.
  * 
  * @param tag
  *            the name of the tag
  * @param obj
  *            an identifier to find the marked content
  * @param page
  *            a page dictionary
  * @throws IOException
  */
 public virtual void ParseTag(String tag, PdfObject obj, PdfDictionary page) {
     // if the identifier is a number, we can extract the content right away
     if (obj is PdfNumber) {
         PdfNumber mcid = (PdfNumber) obj;
         RenderFilter filter = new MarkedContentRenderFilter(mcid.IntValue);
         ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
         FilteredTextRenderListener listener = new FilteredTextRenderListener(strategy, new RenderFilter[]{filter});
         PdfContentStreamProcessor processor = new PdfContentStreamProcessor(
                 listener);
         processor.ProcessContent(PdfReader.GetPageContent(page), page
                 .GetAsDict(PdfName.RESOURCES));
         outp.Write(XMLUtil.EscapeXML(listener.GetResultantText(), true));
     }
     // if the identifier is an array, we call the parseTag method
     // recursively
     else if (obj is PdfArray) {
         PdfArray arr = (PdfArray) obj;
         int n = arr.Size;
         for (int i = 0; i < n; i++) {
             ParseTag(tag, arr[i], page);
             if (i < n - 1)
                 outp.WriteLine();
         }
     }
     // if the identifier is a dictionary, we get the resources from the
     // dictionary
     else if (obj is PdfDictionary) {
         PdfDictionary mcr = (PdfDictionary) obj;
         ParseTag(tag, mcr.GetDirectObject(PdfName.MCID), mcr
                 .GetAsDict(PdfName.PG));
     }
 }
开发者ID:,项目名称:,代码行数:43,代码来源:

示例5: InspectChildDictionary

        /**
         * If the child of a structured element is a dictionary, we inspect the
         * child; we may also draw a tag.
         * 
         * @param k
         *            the child dictionary to inspect
         */
        virtual public void InspectChildDictionary(PdfDictionary k, bool inspectAttributes) {
            if (k == null)
                return;
            PdfName s = k.GetAsName(PdfName.S);
            if (s != null) {
                String tagN = PdfName.DecodeName(s.ToString());
			    String tag = FixTagName(tagN);
                outp.Write("<");
                outp.Write(tag);
                if (inspectAttributes) {
                    PdfDictionary a = k.GetAsDict(PdfName.A);
                    if (a != null) {
                        Dictionary<PdfName, PdfObject>.KeyCollection keys = a.Keys;
                        foreach (PdfName key in keys) {
                            outp.Write(' ');
                            PdfObject value = a.Get(key);
                            value = PdfReader.GetPdfObject(value);
                            outp.Write(XmlName(key));
                            outp.Write("=\"");
                            outp.Write(value.ToString());
                            outp.Write("\"");
                        }
                    }
                }
                outp.Write(">");
                PdfDictionary dict = k.GetAsDict(PdfName.PG);
                if (dict != null)
                    ParseTag(tagN, k.GetDirectObject(PdfName.K), dict);
                InspectChild(k.GetDirectObject(PdfName.K));
                outp.Write("</");
                outp.Write(tag);
                outp.WriteLine(">");
            } else
                InspectChild(k.GetDirectObject(PdfName.K));
        }
开发者ID:,项目名称:,代码行数:42,代码来源:

示例6: Parse

 /**
  * Parses the content of a page, replacing appearances of annotations
  * with Form XObjects.
  * @param page a page dictionary
  * @throws IOException
  */
 virtual public void Parse(PdfDictionary page, PdfIndirectReference pageref) {
     LOGGER.Info("Parsing page with reference " + pageref);
     // initializing member variables
     baos = new MemoryStream();
     this.page = page;
     this.pageref = pageref;
     
     structParents = page.GetAsNumber(PdfName.STRUCTPARENTS);
     if(structParents == null)
         throw new DocumentException(MessageLocalization.GetComposedMessage("can.t.read.document.structure"));
     annots = page.GetAsArray(PdfName.ANNOTS);
     if(annots == null)
         annots = new PdfArray();
     PdfDictionary resources = page.GetAsDict(PdfName.RESOURCES);
     xobjects = resources.GetAsDict(PdfName.XOBJECT);
     if (xobjects == null) {
         xobjects = new PdfDictionary();
         resources.Put(PdfName.XOBJECT, xobjects);
     }
     // parsing the content stream of the page
     PRStream stream = (PRStream) page.GetAsStream(PdfName.CONTENTS);
     byte[] contentBytes = PdfReader.GetStreamBytes(stream);
     PRTokeniser tokeniser = new PRTokeniser(new RandomAccessFileOrArray(RASFACTORY.CreateSource(contentBytes)));
     PdfContentParser ps = new PdfContentParser(tokeniser);
     List<PdfObject> operands = new List<PdfObject>();
     while (ps.Parse(operands).Count > 0) {
         PdfLiteral opr = (PdfLiteral) operands[operands.Count - 1];
         ProcessOperator(opr, operands);
     }
     // dealing with orphans
     while (items.Count > 0 && items[0].GetPageref() == pageref.Number) {
         StructureItem item = items[0];
         if (item is StructureObject) {
             ConvertToXObject((StructureObject) item);
             items.RemoveAt(0);
         }
     }
     if(annots.Length == 0) {
         page.Remove(PdfName.ANNOTS);
     }
     else {
         PdfDictionary annot;
         for(int i = 0; i < annots.Size; i++) {
             annot = annots.GetAsDict(i);
             if(annot.GetAsNumber(PdfName.STRUCTPARENT) == null)
                 throw new DocumentException(MessageLocalization.GetComposedMessage("could.not.flatten.file.untagged.annotations.found"));
         }
     }
     // replacing the content stream
     baos.Flush();
     baos.Close();
     stream.SetData(baos.ToArray());
     // showing how many items are left
     LOGGER.Info(String.Format("There are {0} items left for processing", items.Count));
 }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:61,代码来源:MCParser.cs

示例7: GetDictionaryDetail

 /**
  * Shows the detail of a dictionary.
  * @param dic   the dictionary of which you want the detail
  * @param depth the depth of the current dictionary (for nested dictionaries)
  * @return  a String representation of the dictionary
  */
 public static  String GetDictionaryDetail(PdfDictionary dic, int depth){
     StringBuilder builder = new StringBuilder();
     builder.Append('(');
     IList<PdfName> subDictionaries = new List<PdfName>();
     foreach (PdfName key in dic.Keys) {
         PdfObject val = dic.GetDirectObject(key);
         if (val.IsDictionary())
             subDictionaries.Add(key);
         builder.Append(key);
         builder.Append('=');
         builder.Append(val);
         builder.Append(", ");
     }
     builder.Length = builder.Length-2;
     builder.Append(')');
     foreach (PdfName pdfSubDictionaryName in subDictionaries) {
         builder.Append('\n');
         for (int i = 0; i < depth+1; i++){
             builder.Append('\t');
         }
         builder.Append("Subdictionary ");
         builder.Append(pdfSubDictionaryName);
         builder.Append(" = ");
         builder.Append(GetDictionaryDetail(dic.GetAsDict(pdfSubDictionaryName), depth+1));
     }
     return builder.ToString();
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:33,代码来源:PdfContentReaderTool.cs

示例8: GetXObjectDetail

        /**
         * Displays a summary of the entries in the XObject dictionary for the stream
         * @param resourceDic the resource dictionary for the stream
         * @return a string with the summary of the entries
         * @throws IOException
         * @since 5.0.2
         */
        public static String GetXObjectDetail(PdfDictionary resourceDic) {
            StringBuilder sb = new StringBuilder();
            
            PdfDictionary xobjects = resourceDic.GetAsDict(PdfName.XOBJECT);
            if (xobjects == null)
                return "No XObjects";
            foreach (PdfName entryName in xobjects.Keys) {
                PdfStream xobjectStream = xobjects.GetAsStream(entryName);
                
                sb.Append("------ " + entryName + " - subtype = " + xobjectStream.Get(PdfName.SUBTYPE) + " = " + xobjectStream.GetAsNumber(PdfName.LENGTH) + " bytes ------\n");
                
                if (!xobjectStream.Get(PdfName.SUBTYPE).Equals(PdfName.IMAGE)){
                
                    byte[] contentBytes = ContentByteUtils.GetContentBytesFromContentObject(xobjectStream);

                    foreach (byte b in contentBytes) {
                        sb.Append((char)b);
                    }
        
                    sb.Append("------ " + entryName + " - subtype = " + xobjectStream.Get(PdfName.SUBTYPE) + "End of Content" + "------\n");
                }
            }
           
            return sb.ToString();
        }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:32,代码来源:PdfContentReaderTool.cs


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