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

C# PdfObject类代码示例

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

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



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

示例1: Decode

        public byte[] Decode(PdfObject decodedObject, byte[] inputData, DecodeParameters decodeParameters)
        {
            FIBITMAP myImage = new FIBITMAP();
            using (MemoryStream stream = new MemoryStream(inputData))
            {
                myImage = FreeImage.LoadFromStream(stream);
            }

            Bitmap bitmap = FreeImage.GetBitmap(myImage);

            decodedObject.ColorSpace = ColorSpace.RGB;

            byte[] result = new byte[decodedObject.Width * decodedObject.Height * 3];

            for (int i = 0; i < decodedObject.Width; i++)
            {
                for (int j = 0; j < decodedObject.Height; j++)
                {
                    Color pixel = bitmap.GetPixel(i, j);

                    int index = j * decodedObject.Width + i;
                    result[index * 3] = pixel.R;
                    result[index * 3 + 1] = pixel.G;
                    result[index * 3 + 2] = pixel.B;
                }
            }

            return result;
        }
开发者ID:Motaz-Al-Zoubi,项目名称:xaml-sdk,代码行数:29,代码来源:JpxDecoder.cs


示例2: PdfReference

    // About PdfReference 
    // 
    // * A PdfReference holds the either ObjectID or the PdfObject or both.
    // 
    // * Each PdfObject has a PdfReference if and only if it is an indirect object. Direct objects have
    //   no PdfReference, because they are embedded in a parent objects.
    //
    // * PdfReference objects are used to reference PdfObject instances. A value in a PDF dictionary
    //   or array that is a PdfReference represents an indirect reference. A value in a PDF dictionary or
    //   or array that is a PdfObject represents a direct (or embeddded) object.
    //
    // * When a PDF file is imported, the PdfXRefTable is filled with PdfReference objects keeping the
    //   ObjectsIDs and file positions (offsets) of all indirect objects.
    //
    // * Indirect objects can easily be renumbered because they do not rely on their ObjectsIDs.
    //
    // * During modification of a document the ObjectID of an indirect object has no meaning,
    //   except that they must be different in pairs.

    /// <summary>
    /// Initializes a new PdfReference instance for the specified indirect object.
    /// </summary>
    public PdfReference(PdfObject pdfObject)
    {
      Debug.Assert(pdfObject.Reference == null, "Must not create iref for an object that already has one.");
      this.value = pdfObject;
#if UNIQUE_IREF && DEBUG
      this.uid = ++PdfReference.counter;
#endif
    }
开发者ID:AnthonyNystrom,项目名称:Pikling,代码行数:30,代码来源:PdfReference.cs


示例3: PdfDictionary

        internal PdfDictionary(
			PdfObject	Parent
			)
        {
            KeyValue = new List<PdfKeyValue>();
            this.Parent = Parent;
            this.Document = Parent.Document;
            return;
        }
开发者ID:UnionMexicanaDelNorte,项目名称:cheques,代码行数:9,代码来源:PdfDictionary.cs


示例4: CacheObject

 virtual public void CacheObject(PdfIndirectReference iref, PdfObject obj) {
     if (obj.Type == 0) {
         cachedObjects[new RefKey(iref)] = obj;
     }
     else if (obj is PdfDictionary) {
         cachedObjects[new RefKey(iref)] = CleverPdfDictionaryClone((PdfDictionary) obj);
     }
     else if (obj.IsArray()) {
         cachedObjects[new RefKey(iref)] = CleverPdfArrayClone((PdfArray) obj);
     }
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:11,代码来源:PdfAChecker.cs


示例5: Process

 /**
  * Processes an object. If the object is indirect, it is added to the
  * list of resources. If not, it is just processed.
  * @param object    the object to process
  */
 protected void Process(PdfObject @object) {
     PRIndirectReference @ref = @object.IndRef;
     if (@ref == null) {
         LoopOver(@object);
     } else {
         bool containsKey = resources.ContainsKey(@ref.Number);
         resources[@ref.Number] = @object;
         if (!containsKey)
             LoopOver(@object);
     }
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:16,代码来源:PdfResourceCounter.cs


示例6: Add

        /// <summary>
        /// Adds a PdfObject to the table.
        /// </summary>
        public void Add(PdfObject value)
        {
            if (value.Owner == null)
                value.Document = _document;
            else
                Debug.Assert(value.Owner == _document);

            if (value.ObjectID.IsEmpty)
                value.SetObjectID(GetNewObjectNumber(), 0);

            if (ObjectTable.ContainsKey(value.ObjectID))
                throw new InvalidOperationException("Object already in table.");

            ObjectTable.Add(value.ObjectID, value.Reference);
        }
开发者ID:Sl0vi,项目名称:PDFsharp,代码行数:18,代码来源:PdfCrossReferenceTable.cs


示例7: Add

 internal 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);
         PdfCrossReference pxref = new PdfCrossReference(refNumber, position);
         xrefs.Remove(pxref);
         xrefs[pxref] = null;
         indirect.WriteTo(writer.Os);
         position = writer.Os.Counter;
         return indirect;
     }
 }
开发者ID:pixelia-es,项目名称:RazorPDF2,代码行数:19,代码来源:PdfWriter.cs


示例8: TextToPdfString

        ////////////////////////////////////////////////////////////////////
        // C# string text to PDF strings only
        ////////////////////////////////////////////////////////////////////
        internal String TextToPdfString(
			String		Text,
			PdfObject	Parent
			)
        {
            // convert C# string to byte array
            Byte[] ByteArray = TextToByteArray(Text);

            // encryption is active. PDF string must be encrypted except for encryption dictionary
            if(Encryption != null && Encryption != Parent) ByteArray = Encryption.EncryptByteArray(Parent.ObjectNumber, ByteArray);

            // convert byte array to PDF string format
            return(ByteArrayToPdfString(ByteArray));
        }
开发者ID:UnionMexicanaDelNorte,项目名称:cheques,代码行数:17,代码来源:PdfDocument.cs


示例9: GetDirectStream

 virtual protected PdfStream GetDirectStream(PdfObject obj) {
     obj = GetDirectObject(obj);
     if (obj != null && obj.IsStream())
         return (PdfStream) obj;
     return null;
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:6,代码来源:PdfAChecker.cs


示例10: GetDirectArray

 virtual protected PdfArray GetDirectArray(PdfObject obj) {
     obj = GetDirectObject(obj);
     if (obj != null && obj.IsArray())
         return (PdfArray) obj;
     return null;
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:6,代码来源:PdfAChecker.cs


示例11: GetDirectDictionary

 virtual protected PdfDictionary GetDirectDictionary(PdfObject obj) {
     obj = GetDirectObject(obj);
     if (obj != null && obj is PdfDictionary)
         return (PdfDictionary) obj;
     return null;
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:6,代码来源:PdfAChecker.cs


示例12: FindColorspace

 /**
  * Sets state of this object according to the color space 
  * @param colorspace the colorspace to use
  * @param allowIndexed whether indexed color spaces will be resolved (used for recursive call)
  * @throws IOException if there is a problem with reading from the underlying stream  
  */
 private void FindColorspace(PdfObject colorspace, bool allowIndexed) {
     if (colorspace == null && bpc == 1){ // handle imagemasks
         stride = (width*bpc + 7) / 8;
         pngColorType = 0;
     }
     else if (PdfName.DEVICEGRAY.Equals(colorspace)) {
         stride = (width * bpc + 7) / 8;
         pngColorType = 0;
     }
     else if (PdfName.DEVICERGB.Equals(colorspace)) {
         if (bpc == 8 || bpc == 16) {
             stride = (width * bpc * 3 + 7) / 8;
             pngColorType = 2;
         }
     }
     else if (colorspace is PdfArray) {
         PdfArray ca = (PdfArray)colorspace;
         PdfObject tyca = ca.GetDirectObject(0);
         if (PdfName.CALGRAY.Equals(tyca)) {
             stride = (width * bpc + 7) / 8;
             pngColorType = 0;
         }
         else if (PdfName.CALRGB.Equals(tyca)) {
             if (bpc == 8 || bpc == 16) {
                 stride = (width * bpc * 3 + 7) / 8;
                 pngColorType = 2;
             }
         }
         else if (PdfName.ICCBASED.Equals(tyca)) {
             PRStream pr = (PRStream)ca.GetDirectObject(1);
             int n = pr.GetAsNumber(PdfName.N).IntValue;
             if (n == 1) {
                 stride = (width * bpc + 7) / 8;
                 pngColorType = 0;
                 icc = PdfReader.GetStreamBytes(pr);
             }
             else if (n == 3) {
                 stride = (width * bpc * 3 + 7) / 8;
                 pngColorType = 2;
                 icc = PdfReader.GetStreamBytes(pr);
             }
         }
         else if (allowIndexed && PdfName.INDEXED.Equals(tyca)) {
             FindColorspace(ca.GetDirectObject(1), false);
             if (pngColorType == 2) {
                 PdfObject id2 = ca.GetDirectObject(3);
                 if (id2 is PdfString) {
                     palette = ((PdfString)id2).GetBytes();
                 }
                 else if (id2 is PRStream) {
                     palette = PdfReader.GetStreamBytes(((PRStream)id2));
                 }
                 stride = (width * bpc + 7) / 8;
                 pngColorType = 3;
             }
         }
     }
 }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:64,代码来源:PdfImageObject.cs


示例13: SetObject

 /// <summary>
 /// Hack for dead objects.
 /// </summary>
 internal void SetObject(PdfObject value)
 {
   this.value = value;
 }
开发者ID:AnthonyNystrom,项目名称:Pikling,代码行数:7,代码来源:PdfReference.cs


示例14: MarkUsed

 private void MarkUsed(PdfObject obj)
 {
     if (!append)
         return;
     ((PdfStamperImp)writer).MarkUsed(obj);
 }
开发者ID:pixelia-es,项目名称:RazorPDF2,代码行数:6,代码来源:AcroFields.cs


示例15: AddToObjStm

 private 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:pixelia-es,项目名称:RazorPDF2,代码行数:20,代码来源:PdfWriter.cs


示例16: FixUpObject_old

    /// <summary>
    /// Replace all indirect references to external objects by their cloned counterparts
    /// owned by the importer document.
    /// </summary>
    void FixUpObject_old(PdfImportedObjectTable iot, PdfObject value)
    {
      // TODO: merge with PdfXObject.FixUpObject
      PdfDictionary dict;
      PdfArray array;
      if ((dict = value as PdfDictionary) != null)
      {
        // Set document for cloned direct objects
        if (dict.Owner == null)
          dict.Document = this.Owner;
        else
          Debug.Assert(dict.Owner == this.Owner);

        // Search for indirect references in all keys
        PdfName[] names = dict.Elements.KeyNames;
        foreach (PdfName name in names)
        {
          PdfItem item = dict.Elements[name];
          // Is item an iref?
          PdfReference iref = item as PdfReference;
          if (iref != null)
          {
            // Does the iref already belong to this document?
            if (iref.Document == this.Owner)
            {
              // Yes: fine
              continue;
            }
            else
            {
              Debug.Assert(iref.Document == iot.ExternalDocument);
              // No: replace with iref of cloned object
              PdfReference newXRef = iot[iref.ObjectID];
              Debug.Assert(newXRef != null);
              Debug.Assert(newXRef.Document == this.Owner);
              dict.Elements[name] = newXRef;
            }
          }
          else if (item is PdfObject)
          {
            // Fix up inner objects
            FixUpObject_old(iot, (PdfObject)item);
          }
        }
      }
      else if ((array = value as PdfArray) != null)
      {
        // Set document for cloned direct objects
        if (array.Owner == null)
          array.Document = this.Owner;
        else
          Debug.Assert(array.Owner == this.Owner);

        // Search for indirect references in all array elements
        int count = array.Elements.Count;
        for (int idx = 0; idx < count; idx++)
        {
          PdfItem item = array.Elements[idx];
          // Is item an iref?
          PdfReference iref = item as PdfReference;
          if (iref != null)
          {
            // Does the iref belongs to this document?
            if (iref.Document == this.Owner)
            {
              // Yes: fine
              continue;
            }
            else
            {
              Debug.Assert(iref.Document == iot.ExternalDocument);
              // No: replace with iref of cloned object
              PdfReference newXRef = iot[iref.ObjectID];
              Debug.Assert(newXRef != null);
              Debug.Assert(newXRef.Document == this.Owner);
              array.Elements[idx] = newXRef;
            }
          }
          else if (item is PdfObject)
          {
            // Fix up inner objects
            FixUpObject_old(iot, (PdfObject)item);
          }
        }
      }
    }
开发者ID:AnthonyNystrom,项目名称:Pikling,代码行数:90,代码来源:PdfFormXObject.cs


示例17: ConstructorHelper

        ////////////////////////////////////////////////////////////////////
        // Initial Object Array
        ////////////////////////////////////////////////////////////////////
        private void ConstructorHelper(
			Double		Width,			// page width
			Double		Height,			// page height
			Double		ScaleFactor,	// scale factor from user units to points (i.e. 72.0 for inch)
			String		FileName,
			Stream		OutputStream
			)
        {
            // set scale factor (user units to points)
            this.ScaleFactor = ScaleFactor;

            // save page default size
            PageSize = new SizeD(Width, Height);

            // PDF document root object the Catalog object
            CatalogObject = new PdfObject(this, ObjectType.Dictionary, "/Catalog");

            // add viewer preferences
            CatalogObject.Dictionary.Add("/ViewerPreferences", "<</PrintScaling/None>>");

            // Parent object for all pages
            PagesObject = new PdfObject(this, ObjectType.Dictionary, "/Pages");

            // add indirect reference to pages within the catalog object
            CatalogObject.Dictionary.AddIndirectReference("/Pages", PagesObject);

            // document id
            DocumentID = RandomByteArray(16);

            // create file using file name
            if(FileName != null)
            {
            // save file name
            this.FileName = FileName;

            // constructor helper
            PdfFile = new PdfBinaryWriter(new FileStream(FileName, FileMode.Create, FileAccess.Write, FileShare.None));
            }

            // write to caller's file or memory stream
            else
            {
            PdfFile = new PdfBinaryWriter(OutputStream);
            }

            // write PDF version number
            PdfFile.WriteString("%PDF-1.7\n");

            // add this comment to tell compression programs that this is a binary file
            PdfFile.WriteString("%\u00b5\u00b5\u00b5\u00b5\n");

            // exit
            return;
        }
开发者ID:UnionMexicanaDelNorte,项目名称:cheques,代码行数:57,代码来源:PdfDocument.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
            */
            internal void WriteCrossReferenceTable(Stream os, PdfIndirectReference root, PdfIndirectReference info, PdfIndirectReference encryption, PdfObject fileID, int 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;
                ArrayList sections = new ArrayList();
                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 = 4;
                    uint mask = 0xff000000;
                    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((int)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);
                    IEnumerator i = xrefs.Keys;
                    i.MoveNext();
                    for (int k = 0; k < sections.Count; k += 2) {
                        first = (int)sections[k];
                        len = (int)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:pixelia-es,项目名称:RazorPDF2,代码行数:93,代码来源:PdfWriter.cs


示例19: GetPropertiesDictionary

            private PdfDictionary GetPropertiesDictionary(PdfObject operand1, ResourceDictionary resources){
                if (operand1.IsDictionary())
                    return (PdfDictionary)operand1;

                PdfName dictionaryName = ((PdfName)operand1);
                return resources.GetAsDict(dictionaryName);
            }
开发者ID:Gianluigi,项目名称:dssnet,代码行数:7,代码来源:PdfContentStreamProcessor.cs


示例20: GetDirectObject

 virtual protected PdfObject GetDirectObject(PdfObject obj) {
     if (obj == null)
         return null;
     //use counter to prevent indirect reference cycling
     int count = 0;
     // resolve references
     while (obj is PdfIndirectReference) {
         PdfObject curr;
         if (obj.IsIndirect())
             curr = PdfReader.GetPdfObject(obj);
         else
             cachedObjects.TryGetValue(new RefKey((PdfIndirectReference) obj), out curr);
         if (curr == null) break;
         obj = curr;
         //10 - is max allowed reference chain
         if (count++ > 10)
             break;
     }
     return obj;
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:20,代码来源:PdfAChecker.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# PdfWriter类代码示例发布时间:2022-05-24
下一篇:
C# PdfName类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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