• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# pdf.PdfObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中iTextSharp.text.pdf.PdfObject的典型用法代码示例。如果您正苦于以下问题:C# PdfObject类的具体用法?C# PdfObject怎么用?C# PdfObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PdfObject类属于iTextSharp.text.pdf命名空间,在下文中一共展示了PdfObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SetField

 internal bool SetField(String field, PdfObject value) {
     Hashtable map = fields;
     StringTokenizer tk = new StringTokenizer(field, ".");
     if (!tk.HasMoreTokens())
         return false;
     while (true) {
         String s = tk.NextToken();
         Object obj = map[s];
         if (tk.HasMoreTokens()) {
             if (obj == null) {
                 obj = new Hashtable();
                 map[s] = obj;
                 map = (Hashtable)obj;
                 continue;
             }
             else if (obj is Hashtable)
                 map = (Hashtable)obj;
             else
                 return false;
         }
         else {
             if (!(obj is Hashtable)) {
                 map[s] = value;
                 return true;
             }
             else
                 return false;
         }
     }
 }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:30,代码来源:FdfWriter.cs


示例2: GetDirectObject

 public static PdfObject GetDirectObject(PdfObject obj) {
     if (obj == null)
         return null;
     while (obj.IsIndirect())
         obj = PdfReader.GetPdfObjectRelease(obj);
     return obj;
 }
开发者ID:,项目名称:,代码行数:7,代码来源:


示例3: SetField

 internal bool SetField(String field, PdfObject value) {
     Dictionary<String, Object> map = fields;
     StringTokenizer tk = new StringTokenizer(field, ".");
     if (!tk.HasMoreTokens())
         return false;
     while (true) {
         String s = tk.NextToken();
         Object obj;
         map.TryGetValue(s, out obj);
         if (tk.HasMoreTokens()) {
             if (obj == null) {
                 obj = new Dictionary<String, Object>();
                 map[s] = obj;
                 map = (Dictionary<string,object>)obj;
                 continue;
             }
             else if (obj is Dictionary<String, Object>)
                 map = (Dictionary<String, Object>)obj;
             else
                 return false;
         }
         else {
             if (!(obj is Dictionary<String, Object>)) {
                 map[s] = value;
                 return true;
             }
             else
                 return false;
         }
     }
 }
开发者ID:,项目名称:,代码行数:31,代码来源:


示例4: GetContentBytesFromContentObject

 /**
  * Gets the content bytes from a content object, which may be a reference
  * a stream or an array.
  * @param contentObject the object to read bytes from
  * @return the content bytes
  * @throws IOException
  */
 public static byte[] GetContentBytesFromContentObject(PdfObject contentObject) {
     byte[] result;
     switch (contentObject.Type)
     {
         case PdfObject.INDIRECT:
             PRIndirectReference refi = (PRIndirectReference) contentObject;
             PdfObject directObject = PdfReader.GetPdfObjectRelease(refi);
             result = GetContentBytesFromContentObject(directObject);
             break;
         case PdfObject.STREAM:
             PRStream stream = (PRStream) PdfReader.GetPdfObjectRelease(contentObject);
             result = PdfReader.GetStreamBytes(stream);
             break;
         case PdfObject.ARRAY:
             // Stitch together all content before calling ProcessContent(), because
             // ProcessContent() resets state.
             MemoryStream allBytes = new MemoryStream();
             PdfArray contentArray = (PdfArray) contentObject;
             ListIterator<PdfObject> iter = contentArray.GetListIterator();
             while (iter.HasNext()) {
                 PdfObject element = iter.Next();
                 byte[] b;
                 allBytes.Write(b = GetContentBytesFromContentObject(element), 0, b.Length);
                 allBytes.WriteByte((byte)' ');
             }
             result = allBytes.ToArray();
             break;
         default:
             String msg = "Unable to handle Content of type " + contentObject.GetType();
         throw new InvalidOperationException(msg);
     }
     return result;
 }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:40,代码来源:ContentByteUtils.cs


示例5: AddRange

 internal void AddRange(PdfString from, PdfString to, PdfObject code) {
     byte[] a1 = DecodeStringToByte(from);
     byte[] a2 = DecodeStringToByte(to);
     if (a1.Length != a2.Length || a1.Length == 0)
         throw new ArgumentException("Invalid map.");
     byte[] sout = null;
     if (code is PdfString)
         sout = DecodeStringToByte((PdfString)code);
     int start = a1[a1.Length - 1] & 0xff;
     int end = a2[a2.Length - 1] & 0xff;
     for (int k = start; k <= end; ++k) {
         a1[a1.Length - 1] = (byte)k;
         PdfString s = new PdfString(a1);
         s.SetHexWriting(true);
         if (code is PdfArray) {
             AddChar(s, ((PdfArray)code)[k - start]);
         }
         else if (code is PdfNumber) {
             int nn = ((PdfNumber)code).IntValue + k - start;
             AddChar(s, new PdfNumber(nn));
         }
         else if (code is PdfString) {
             PdfString s1 = new PdfString(sout);
             s1.SetHexWriting(true);
             ++sout[sout.Length - 1];
             AddChar(s, s1);
         }
     }
 }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:29,代码来源:AbstractCMap.cs


示例6: AddChar

 internal override void AddChar(PdfString mark, PdfObject code) {
     if (!(code is PdfNumber))
         return;
     int codepoint;
     String s = DecodeStringToUnicode(mark);
     if (Utilities.IsSurrogatePair(s, 0))
         codepoint = Utilities.ConvertToUtf32(s, 0);
     else
         codepoint = (int)s[0];
     map[((PdfNumber)code).IntValue] = codepoint;
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:11,代码来源:CMapCidUni.cs


示例7: AddToBody

 /**
 * Adds an object to the PDF body.
 * @param object
 * @param refNumber
 * @param inObjStm
 * @return a PdfIndirectObject
 * @throws IOException
 */
 public PdfIndirectObject AddToBody(PdfObject objecta, int refNumber, bool inObjStm) {
     PdfIndirectObject iobj = body.Add(objecta, refNumber, inObjStm);
     return iobj;
 }
开发者ID:,项目名称:,代码行数:12,代码来源:


示例8: PdfTrailer

 // constructors
 
 /**
 * Constructs a PDF-Trailer.
 *
 * @param        size        the number of entries in the <CODE>PdfCrossReferenceTable</CODE>
 * @param        offset      offset of the <CODE>PdfCrossReferenceTable</CODE>
 * @param        root        an indirect reference to the root of the PDF document
 * @param        info        an indirect reference to the info object of the PDF document
 * @param encryption
 * @param fileID
 * @param prevxref
 */
 
 public PdfTrailer(int size, long offset, PdfIndirectReference root, PdfIndirectReference info, PdfIndirectReference encryption, PdfObject fileID, long prevxref) {
     this.offset = offset;
     Put(PdfName.SIZE, new PdfNumber(size));
     Put(PdfName.ROOT, root);
     if (info != null) {
         Put(PdfName.INFO, info);
     }
     if (encryption != null)
         Put(PdfName.ENCRYPT, encryption);
     if (fileID != null)
         Put(PdfName.ID, fileID);
     if (prevxref > 0)
         Put(PdfName.PREV, new PdfNumber(prevxref));
 }
开发者ID:,项目名称:,代码行数:28,代码来源:


示例9: Add

 virtual internal protected PdfIndirectObject Add(PdfObject objecta, int refNumber, bool inObjStm) {
     if (inObjStm && objecta.CanBeInObjStm() && writer.FullCompression) {
         PdfCrossReference pxref = AddToObjStm(objecta, refNumber);
         PdfIndirectObject indirect = new PdfIndirectObject(refNumber, objecta, writer);
         xrefs.Remove(pxref);
         xrefs[pxref] = null;
         return indirect;
     }
     else {
         PdfIndirectObject indirect = new PdfIndirectObject(refNumber, objecta, writer);
         Write(indirect, refNumber);
         return indirect;
     }
 }
开发者ID:,项目名称:,代码行数:14,代码来源:


示例10: SweepKids

 internal void SweepKids(PdfObject obj) {
     PdfObject oo = PdfReader.KillIndirect(obj);
     if (oo == null || !oo.IsDictionary())
         return;
     PdfDictionary dic = (PdfDictionary)oo;
     PdfArray kids = (PdfArray)PdfReader.KillIndirect(dic.Get(PdfName.KIDS));
     if (kids == null)
         return;
     for (int k = 0; k < kids.Size; ++k) {
         SweepKids(kids.GetPdfObject(k));
     }
 }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:12,代码来源:PdfStamperImp.cs


示例11: AddViewerPreference

 /**
 * @see com.lowagie.text.pdf.interfaces.PdfViewerPreferences#addViewerPreference(com.lowagie.text.pdf.PdfName, com.lowagie.text.pdf.PdfObject)
 */
 public void AddViewerPreference(PdfName key, PdfObject value) {
     fc.AddViewerPreference(key, value); 
 }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:6,代码来源:PdfCopyForms.cs


示例12: AddViewerPreference

 /** @see com.lowagie.text.pdf.interfaces.PdfViewerPreferences#addViewerPreference(com.lowagie.text.pdf.PdfName, com.lowagie.text.pdf.PdfObject) */
 internal void AddViewerPreference(PdfName key, PdfObject value) {
     this.viewerPreferences.AddViewerPreference(key, value);
 }
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:4,代码来源:PdfDocument.cs


示例13: AddToObjStm

 protected PdfWriter.PdfBody.PdfCrossReference AddToObjStm(PdfObject obj, int nObj) {
     if (numObj >= OBJSINSTREAM)
         FlushObjStm();
     if (index == null) {
         index = new ByteBuffer();
         streamObjects = new ByteBuffer();
         currentObjNum = IndirectReferenceNumber;
         numObj = 0;
     }
     int p = streamObjects.Size;
     int idx = numObj++;
     PdfEncryption enc = writer.crypto;
     writer.crypto = null;
     obj.ToPdf(writer, streamObjects);
     writer.crypto = enc;
     streamObjects.Append(' ');
     index.Append(nObj).Append(' ').Append(p).Append(' ');
     return new PdfWriter.PdfBody.PdfCrossReference(2, nObj, currentObjNum, idx);
 }
开发者ID:,项目名称:,代码行数:19,代码来源:


示例14: SetDefaultColorspace

 /**
 * Sets the default colorspace that will be applied to all the document.
 * The colorspace is only applied if another colorspace with the same name
 * is not present in the content.
 * <p>
 * The colorspace is applied immediately when creating templates and at the page
 * end for the main document content.
 * @param key the name of the colorspace. It can be <CODE>PdfName.DEFAULTGRAY</CODE>, <CODE>PdfName.DEFAULTRGB</CODE>
 * or <CODE>PdfName.DEFAULTCMYK</CODE>
 * @param cs the colorspace. A <CODE>null</CODE> or <CODE>PdfNull</CODE> removes any colorspace with the same name
 */    
 public void SetDefaultColorspace(PdfName key, PdfObject cs) {
     if (cs == null || cs.IsNull())
         defaultColorspace.Remove(key);
     defaultColorspace.Put(key, cs);
 }
开发者ID:,项目名称:,代码行数:16,代码来源:


示例15: AddViewerPreference

 /** Adds a viewer preference
 * @param preferences the viewer preferences
 * @see PdfViewerPreferences#addViewerPreference
 */
 public override void AddViewerPreference(PdfName key, PdfObject value) {
     useVp = true;
     this.viewerPreferences.AddViewerPreference(key, value);
 }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:8,代码来源:PdfStamperImp.cs


示例16: MarkUsed

 virtual public void MarkUsed(PdfObject obj) {
     if (append && obj != null) {
         PRIndirectReference ref_p = null;
         if (obj.Type == PdfObject.INDIRECT)
             ref_p = (PRIndirectReference)obj;
         else
             ref_p = obj.IndRef;
         if (ref_p != null)
             marked[ref_p.Number] = 1;
     }
 }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:11,代码来源:PdfStamperImp.cs


示例17: FindAllObjects

 internal static void FindAllObjects(PdfReader reader, PdfObject obj, IntHashtable hits) {
     if (obj == null)
         return;
     switch (obj.Type) {
         case PdfObject.INDIRECT:
             PRIndirectReference iref = (PRIndirectReference)obj;
             if (reader != iref.Reader)
                 return;
             if (hits.ContainsKey(iref.Number))
                 return;
             hits[iref.Number] = 1;
             FindAllObjects(reader, PdfReader.GetPdfObject(obj), hits);
             return;
         case PdfObject.ARRAY:
             PdfArray a = (PdfArray)obj;
             for (int k = 0; k < a.Size; ++k) {
                 FindAllObjects(reader, a[k], hits);
             }
             return;
         case PdfObject.DICTIONARY:
         case PdfObject.STREAM:
             PdfDictionary dic = (PdfDictionary)obj;
             foreach (PdfName name in dic.Keys) {
                 FindAllObjects(reader, dic.Get(name), hits);
             }
             return;
     }
 }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:28,代码来源:PdfStamperImp.cs


示例18: WriteCrossReferenceTable

 /**
 * Returns the CrossReferenceTable of the <CODE>Body</CODE>.
 * @param os
 * @param root
 * @param info
 * @param encryption
 * @param fileID
 * @param prevxref
 * @throws IOException
 */
 virtual public void WriteCrossReferenceTable(Stream os, PdfIndirectReference root, PdfIndirectReference info, PdfIndirectReference encryption, PdfObject fileID, long prevxref) {
     int refNumber = 0;
     if (writer.FullCompression) {
         FlushObjStm();
         refNumber = IndirectReferenceNumber;
         xrefs[new PdfCrossReference(refNumber, position)] = null;
     }
     int first = ((PdfCrossReference)xrefs.GetMinKey()).Refnum;
     int len = 0;
     List<int> sections = new List<int>();
     foreach (PdfCrossReference entry in xrefs.Keys) {
         if (first + len == entry.Refnum)
             ++len;
         else {
             sections.Add(first);
             sections.Add(len);
             first = entry.Refnum;
             len = 1;
         }
     }
     sections.Add(first);
     sections.Add(len);
     if (writer.FullCompression) {
         int mid = 5;
         long mask = 0xff00000000L;
         for (; mid > 1; --mid) {
             if ((mask & position) != 0)
                 break;
             mask >>= 8;
         }
         ByteBuffer buf = new ByteBuffer();
         
         foreach (PdfCrossReference entry in xrefs.Keys) {
             entry.ToPdf(mid, buf);
         }
         PdfStream xr = new PdfStream(buf.ToByteArray());
         buf = null;
         xr.FlateCompress(writer.CompressionLevel);
         xr.Put(PdfName.SIZE, new PdfNumber(Size));
         xr.Put(PdfName.ROOT, root);
         if (info != null) {
             xr.Put(PdfName.INFO, info);
         }
         if (encryption != null)
             xr.Put(PdfName.ENCRYPT, encryption);
         if (fileID != null)
             xr.Put(PdfName.ID, fileID);
         xr.Put(PdfName.W, new PdfArray(new int[]{1, mid, 2}));
         xr.Put(PdfName.TYPE, PdfName.XREF);
         PdfArray idx = new PdfArray();
         for (int k = 0; k < sections.Count; ++k)
             idx.Add(new PdfNumber(sections[k]));
         xr.Put(PdfName.INDEX, idx);
         if (prevxref > 0)
             xr.Put(PdfName.PREV, new PdfNumber(prevxref));
         PdfEncryption enc = writer.crypto;
         writer.crypto = null;
         PdfIndirectObject indirect = new PdfIndirectObject(refNumber, xr, writer);
         indirect.WriteTo(writer.Os);
         writer.crypto = enc;
     }
     else {
         byte[] tmp = GetISOBytes("xref\n");
         os.Write(tmp, 0, tmp.Length);
         System.Collections.IEnumerator i = xrefs.Keys;
         i.MoveNext();
         for (int k = 0; k < sections.Count; k += 2) {
             first = sections[k];
             len = sections[k + 1];
             tmp = GetISOBytes(first.ToString());
             os.Write(tmp, 0, tmp.Length);
             os.WriteByte((byte)' ');
             tmp = GetISOBytes(len.ToString());
             os.Write(tmp, 0, tmp.Length);
             os.WriteByte((byte)'\n');
             while (len-- > 0) {
                 ((PdfCrossReference)i.Current).ToPdf(os);
                 i.MoveNext();
             }
         }
     }
 }
开发者ID:,项目名称:,代码行数:92,代码来源:


示例19: SetAccessibleAttribute

 virtual public void SetAccessibleAttribute(PdfName key, PdfObject value) {
     if (accessibleAttributes == null)
         accessibleAttributes = new Dictionary<PdfName, PdfObject>();
     accessibleAttributes[key] = value;
 }
开发者ID:,项目名称:,代码行数:5,代码来源:


示例20: AddViewerPreference

 /** Adds a viewer preference
 * @param preferences the viewer preferences
 * @see PdfViewerPreferences#addViewerPreference
 */
 public virtual void AddViewerPreference(PdfName key, PdfObject value) {
     pdf.AddViewerPreference(key, value);
 }
开发者ID:,项目名称:,代码行数:7,代码来源:



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# pdf.PdfOutline类代码示例发布时间:2022-05-26
下一篇:
C# pdf.PdfNumber类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap