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

C# pdf.PRStream类代码示例

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

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



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

示例1: PRStream

 public PRStream(PRStream stream, PdfDictionary newDic) {
     reader = stream.reader;
     offset = stream.offset;
     length = stream.Length;
     compressed = stream.compressed;
     compressionLevel = stream.compressionLevel;
     streamBytes = stream.streamBytes;
     bytes = stream.bytes;
     objNum = stream.objNum;
     objGen = stream.objGen;
     if (newDic != null)
         Merge(newDic);
     else
         Merge(stream);
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:15,代码来源:PRStream.cs


示例2: SetPageContent

 /** Sets the contents of the page.
 * @param content the new page content
 * @param pageNum the page number. 1 is the first
 * @since   2.1.3   (the method already existed without param compressionLevel)
 */
 virtual public void SetPageContent(int pageNum, byte[] content, int compressionLevel) {
     PdfDictionary page = GetPageN(pageNum);
     if (page == null)
         return;
     PdfObject contents = page.Get(PdfName.CONTENTS);
     freeXref = -1;
     KillXref(contents);
     if (freeXref == -1) {
         xrefObj.Add(null);
         freeXref = xrefObj.Count - 1;
     }
     page.Put(PdfName.CONTENTS, new PRIndirectReference(this, freeXref));
     xrefObj[freeXref] = new PRStream(this, content, compressionLevel);
 }
开发者ID:,项目名称:,代码行数:19,代码来源:


示例3: ByteStore

 internal ByteStore(PRStream str)
 {
     md5 = HashAlgorithm.Create("MD5");
     ByteBuffer bb = new ByteBuffer();
     int level = 100;
     SerObject(str, level, bb);
     this.b = bb.ToByteArray();
     md5 = null;
 }
开发者ID:WolfeReiter,项目名称:iTextSharp,代码行数:9,代码来源:PdfSmartCopy.cs


示例4: ByteStore

 internal ByteStore(PRStream str, Dictionary<RefKey, int> serialized)
 {
     ByteBuffer bb = new ByteBuffer();
     int level = 100;
     SerObject(str, level, bb, serialized);
     this.b = bb.ToByteArray();
     hash = CalculateHash(this.b);
 }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:8,代码来源:PdfSmartCopy.cs


示例5: CopyStream

        /**
        * Translate a PRStream to a PdfStream. The data part copies itself.
        */
        protected PdfStream CopyStream(PRStream inp)
        {
            PRStream outp = new PRStream(inp, null);

            foreach (PdfName key in inp.Keys) {
                PdfObject value = inp.Get(key);
                outp.Put(key, CopyObject(value));
            }

            return outp;
        }
开发者ID:boecko,项目名称:iTextSharp,代码行数:14,代码来源:PdfCopy.cs


示例6: PdfImageObject

 /**
  * Creates a PdfImage object.
  * @param stream a PRStream
  * @param colorSpaceDic a color space dictionary
  * @throws IOException
  */
 public PdfImageObject(PRStream stream, PdfDictionary colorSpaceDic)
     : this(stream, PdfReader.GetStreamBytesRaw(stream), colorSpaceDic)
 {
 }
开发者ID:mapo80,项目名称:iTextSharp-Monotouch,代码行数:10,代码来源:PdfImageObject.cs


示例7: GetStreamBytesRaw

 /** Get the content from a stream as it is without applying any filter.
 * @param stream the stream
 * @throws IOException on error
 * @return the stream content
 */    
 public static byte[] GetStreamBytesRaw(PRStream stream) {
     RandomAccessFileOrArray rf = stream.Reader.SafeFile;
     try {
         rf.ReOpen();
         return GetStreamBytesRaw(stream, rf);
     }
     finally {
         try{rf.Close();}catch{}
     }
 }
开发者ID:,项目名称:,代码行数:15,代码来源:


示例8: UpdateImageStream

        private void UpdateImageStream(PRStream imageStream, byte[] newData) {
            PdfImage image = new PdfImage(Image.GetInstance(newData), "", null);

            if (imageStream.Contains(PdfName.SMASK)) {
                image.Put(PdfName.SMASK, imageStream.Get(PdfName.SMASK));
            }

            if (imageStream.Contains(PdfName.MASK)) {
                image.Put(PdfName.MASK, imageStream.Get(PdfName.MASK));
            }

            if (imageStream.Contains(PdfName.SMASKINDATA)) {
                image.Put(PdfName.SMASKINDATA, imageStream.Get(PdfName.SMASKINDATA));
            }

            imageStream.Clear();
            imageStream.PutAll(image);
            imageStream.SetDataRaw(image.GetBytes());
        }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:19,代码来源:PdfCleanUpContentOperator.cs


示例9: ByteStore

 internal ByteStore(PRStream str)
 {
     md5 = new MD5CryptoServiceProvider();
     ByteBuffer bb = new ByteBuffer();
     int level = 100;
     SerObject(str, level, bb);
     this.b = bb.ToByteArray();
     md5 = null;
 }
开发者ID:bmictech,项目名称:iTextSharp,代码行数:9,代码来源:PdfSmartCopy.cs


示例10: PdfImageObject

 /**
  * Creates a PdfImage object.
  * @param stream a PRStream
  * @throws IOException
  */
 public PdfImageObject(PRStream stream) : this(stream, iTextSharp.text.pdf.PdfReader.GetStreamBytesRaw(stream), null) {
 }
开发者ID:labeuze,项目名称:source,代码行数:7,代码来源:PdfImageObject.cs


示例11: Parse

 /// <summary>
 /// Parses a stream object and removes OCGs. </summary>
 /// <param name="stream">	a stream object </param>
 /// <param name="resources">	the resources dictionary of that object (containing info about the OCGs) </param>
 public virtual void Parse(PRStream stream, PdfDictionary resources) {
     baos = new MemoryStream();
     properties = resources.GetAsDict(PdfName.PROPERTIES);
     xobj = new HashSet2<PdfName>();
     PdfDictionary xobjects = resources.GetAsDict(PdfName.XOBJECT);
     if (xobjects != null) {
         // remove XObject (form or image) that belong to an OCG that needs to be removed
         foreach (PdfName name in xobjects.Keys) {
             PRStream xobject = (PRStream) xobjects.GetAsStream(name);
             PdfDictionary oc = xobject.GetAsDict(PdfName.OC);
             if (oc != null) {
                 PdfString ocname = oc.GetAsString(PdfName.NAME);
                 if (ocname != null && ocgs.Contains(ocname.ToString())) {
                     xobj.Add(name);
                 }
             }
         }
         foreach (PdfName name in xobj) {
             xobjects.Remove(name);
         }
     }
     // parse the content stream
     byte[] contentBytes = PdfReader.GetStreamBytes(stream);
     PRTokeniser tokeniser = new PRTokeniser(new RandomAccessFileOrArray(contentBytes));
     PdfContentParser ps = new PdfContentParser(tokeniser);
     List<PdfObject> operands = new List<PdfObject>();
     while (ps.Parse(operands).Count > 0) {
         PdfLiteral @operator = (PdfLiteral) operands[operands.Count - 1];
         ProcessOperator(this, @operator, operands);
     }
     baos.Flush();
     baos.Close();
     stream.SetData(baos.GetBuffer());
 }
开发者ID:,项目名称:,代码行数:38,代码来源:


示例12: ReadOneObjStm

 protected internal PdfObject ReadOneObjStm(PRStream stream, int idx) {
     int first = stream.GetAsNumber(PdfName.FIRST).IntValue;
     byte[] b = GetStreamBytes(stream, tokens.File);
     PRTokeniser saveTokens = tokens;
     tokens = new PRTokeniser(b);
     try {
         int address = 0;
         bool ok = true;
         ++idx;
         for (int k = 0; k < idx; ++k) {
             ok = tokens.NextToken();
             if (!ok)
                 break;
             if (tokens.TokenType != PRTokeniser.TK_NUMBER) {
                 ok = false;
                 break;
             }
             ok = tokens.NextToken();
             if (!ok)
                 break;
             if (tokens.TokenType != PRTokeniser.TK_NUMBER) {
                 ok = false;
                 break;
             }
             address = tokens.IntValue + first;
         }
         if (!ok)
             throw new InvalidPdfException(MessageLocalization.GetComposedMessage("error.reading.objstm"));
         tokens.Seek(address);
         return ReadPRObject();
     }
     finally {
         tokens = saveTokens;
     }
 }
开发者ID:pusp,项目名称:o2platform,代码行数:35,代码来源:PdfReader.cs


示例13: GetStreamBytes

 /** Get the content from a stream applying the required filters.
 * @param stream the stream
 * @param file the location where the stream is
 * @throws IOException on error
 * @return the stream content
 */    
 public static byte[] GetStreamBytes(PRStream stream, RandomAccessFileOrArray file) {
     PdfObject filter = GetPdfObjectRelease(stream.Get(PdfName.FILTER));
     byte[] b = GetStreamBytesRaw(stream, file);
     ArrayList filters = new ArrayList();
     if (filter != null) {
         if (filter.IsName())
             filters.Add(filter);
         else if (filter.IsArray())
             filters = ((PdfArray)filter).ArrayList;
     }
     ArrayList dp = new ArrayList();
     PdfObject dpo = GetPdfObjectRelease(stream.Get(PdfName.DECODEPARMS));
     if (dpo == null || (!dpo.IsDictionary() && !dpo.IsArray()))
         dpo = GetPdfObjectRelease(stream.Get(PdfName.DP));
     if (dpo != null) {
         if (dpo.IsDictionary())
             dp.Add(dpo);
         else if (dpo.IsArray())
             dp = ((PdfArray)dpo).ArrayList;
     }
     String name;
     for (int j = 0; j < filters.Count; ++j) {
         name = ((PdfName)GetPdfObjectRelease((PdfObject)filters[j])).ToString();
         if (name.Equals("/FlateDecode") || name.Equals("/Fl")) {
             b = FlateDecode(b);
             PdfObject dicParam = null;
             if (j < dp.Count) {
                 dicParam = (PdfObject)dp[j];
                 b = DecodePredictor(b, dicParam);
             }
         }
         else if (name.Equals("/ASCIIHexDecode") || name.Equals("/AHx"))
             b = ASCIIHexDecode(b);
         else if (name.Equals("/ASCII85Decode") || name.Equals("/A85"))
             b = ASCII85Decode(b);
         else if (name.Equals("/LZWDecode")) {
             b = LZWDecode(b);
             PdfObject dicParam = null;
             if (j < dp.Count) {
                 dicParam = (PdfObject)dp[j];
                 b = DecodePredictor(b, dicParam);
             }
         }
         else if (name.Equals("/Crypt")) {
         }
         else
             throw new UnsupportedPdfException(MessageLocalization.GetComposedMessage("the.filter.1.is.not.supported", name));
     }
     return b;
 }
开发者ID:pusp,项目名称:o2platform,代码行数:56,代码来源:PdfReader.cs


示例14: GetStreamBytes

 /** Get the content from a stream applying the required filters.
  * @param stream the stream
  * @param file the location where the stream is
  * @throws IOException on error
  * @return the stream content
  */
 public static byte[] GetStreamBytes(PRStream stream, RandomAccessFileOrArray file) {
     byte[] b = GetStreamBytesRaw(stream, file);
     return DecodeBytes(b, stream);
 }
开发者ID:,项目名称:,代码行数:10,代码来源:


示例15: CheckPRStreamLength

 private void CheckPRStreamLength(PRStream stream) {
     int fileLength = tokens.Length;
     int start = stream.Offset;
     bool calc = false;
     int streamLength = 0;
     PdfObject obj = GetPdfObjectRelease(stream.Get(PdfName.LENGTH));
     if (obj != null && obj.Type == PdfObject.NUMBER) {
         streamLength = ((PdfNumber)obj).IntValue;
         if (streamLength + start > fileLength - 20)
             calc = true;
         else {
             tokens.Seek(start + streamLength);
             String line = tokens.ReadString(20);
             if (!line.StartsWith("\nendstream") &&
             !line.StartsWith("\r\nendstream") &&
             !line.StartsWith("\rendstream") &&
             !line.StartsWith("endstream"))
                 calc = true;
         }
     }
     else
         calc = true;
     if (calc) {
         byte[] tline = new byte[16];
         tokens.Seek(start);
         while (true) {
             int pos = tokens.FilePointer;
             if (!tokens.ReadLineSegment(tline))
                 break;
             if (Equalsn(tline, endstream)) {
                 streamLength = pos - start;
                 break;
             }
             if (Equalsn(tline, endobj)) {
                 tokens.Seek(pos - 16);
                 String s = tokens.ReadString(16);
                 int index = s.IndexOf("endstream");
                 if (index >= 0)
                     pos = pos - 16 + index;
                 streamLength = pos - start;
                 break;
             }
         }
     }
     stream.Length = streamLength;
 }
开发者ID:,项目名称:,代码行数:46,代码来源:


示例16: DuplicatePdfObject

 protected internal static PdfObject DuplicatePdfObject(PdfObject original, PdfReader newReader) {
     if (original == null)
         return null;
     switch (original.Type) {
         case PdfObject.DICTIONARY: {
             return DuplicatePdfDictionary((PdfDictionary)original, null, newReader);
         }
         case PdfObject.STREAM: {
             PRStream org = (PRStream)original;
             PRStream stream = new PRStream(org, null, newReader);
             DuplicatePdfDictionary(org, stream, newReader);
             return stream;
         }
         case PdfObject.ARRAY: {
             PdfArray arr = new PdfArray();
             for (ListIterator<PdfObject> it = ((PdfArray)original).GetListIterator(); it.HasNext();) {
                 arr.Add(DuplicatePdfObject((PdfObject)it.Next(), newReader));
             }
             return arr;
         }
         case PdfObject.INDIRECT: {
             PRIndirectReference org = (PRIndirectReference)original;
             return new PRIndirectReference(newReader, org.Number, org.Generation);
         }
         default:
             return original;
     }
 }
开发者ID:,项目名称:,代码行数:28,代码来源:


示例17: CopyStream

 /**
 * Translate a PRStream to a PdfStream. The data part copies itself.
 */
 protected PdfStream CopyStream(PRStream inp) {
     PRStream outp = new PRStream(inp, null);
     
     foreach (PdfName key in inp.Keys) {
         PdfObject value = inp.Get(key);
         parentObjects[value] = inp;
         PdfObject res = CopyObject(value);
         if ((res != null) && !(res is PdfNull))
             outp.Put(key, res);
     }
     
     return outp;
 }
开发者ID:,项目名称:,代码行数:16,代码来源:


示例18: ReadOneObjStm

		virtual protected internal PdfObject ReadOneObjStm (PRStream stream, int idx) {
            int first = stream.GetAsNumber(PdfName.FIRST).IntValue;
            byte[] b = GetStreamBytes(stream, tokens.File);
            PRTokeniser saveTokens = tokens;
            tokens = new PRTokeniser(new RandomAccessFileOrArray(new RandomAccessSourceFactory().CreateSource(b)));
            try {
				int address = 0;
                bool ok = true;
                ++idx;
                for (int k = 0; k < idx; ++k) {
                    ok = tokens.NextToken();
                    if (!ok)
                        break;
                    if (tokens.TokenType != PRTokeniser.TokType.NUMBER) {
                        ok = false;
                        break;
                    }
                    ok = tokens.NextToken();
                    if (!ok)
                        break;
                    if (tokens.TokenType != PRTokeniser.TokType.NUMBER) {
                        ok = false;
                        break;
                    }
                    address = tokens.IntValue + first;
                }
                if (!ok)
                    throw new InvalidPdfException(MessageLocalization.GetComposedMessage("error.reading.objstm"));
                tokens.Seek(address);
                tokens.NextToken();
                PdfObject obj;
                if (tokens.TokenType == PRTokeniser.TokType.NUMBER) {
                    obj = new PdfNumber(tokens.StringValue);
                }
                else {
                    tokens.Seek(address);
                    obj = ReadPRObject();
                }
                return obj;
            }
            finally {
                tokens = saveTokens;
            }
        }
开发者ID:,项目名称:,代码行数:44,代码来源:


示例19: GetFormXObject

 /**
 * Gets the content stream of a page as a PdfStream object.
 * @param   pageNumber          the page of which you want the stream
 * @param   compressionLevel    the compression level you want to apply to the stream
 * @return  a PdfStream object
 * @since   2.1.3 (the method already existed without param compressionLevel)
 */
 internal PdfStream GetFormXObject(int pageNumber, int compressionLevel) {
     PdfDictionary page = reader.GetPageNRelease(pageNumber);
     PdfObject contents = PdfReader.GetPdfObjectRelease(page.Get(PdfName.CONTENTS));
     PdfDictionary dic = new PdfDictionary();
     byte[] bout = null;
     if (contents != null) {
         if (contents.IsStream())
             dic.Merge((PRStream)contents);
         else
             bout = reader.GetPageContent(pageNumber, file);
     }
     else
         bout = new byte[0];
     dic.Put(PdfName.RESOURCES, PdfReader.GetPdfObjectRelease(page.Get(PdfName.RESOURCES)));
     dic.Put(PdfName.TYPE, PdfName.XOBJECT);
     dic.Put(PdfName.SUBTYPE, PdfName.FORM);
     PdfImportedPage impPage = importedPages[pageNumber];
     dic.Put(PdfName.BBOX, new PdfRectangle(impPage.BoundingBox));
     PdfArray matrix = impPage.Matrix;
     if (matrix == null)
         dic.Put(PdfName.MATRIX, IDENTITYMATRIX);
     else
         dic.Put(PdfName.MATRIX, matrix);
     dic.Put(PdfName.FORMTYPE, ONE);
     PRStream stream;
     if (bout == null) {
         stream = new PRStream((PRStream)contents, dic);
     }
     else {
         stream = new PRStream(reader, bout);
         stream.Merge(dic);
     }
     return stream;
 }
开发者ID:,项目名称:,代码行数:41,代码来源:


示例20: ReadObjStm

 virtual protected internal void ReadObjStm(PRStream stream, IntHashtable map) {
     if (stream == null) return;
     int first = stream.GetAsNumber(PdfName.FIRST).IntValue;
     int n = stream.GetAsNumber(PdfName.N).IntValue;
     byte[] b = GetStreamBytes(stream, tokens.File);
     PRTokeniser saveTokens = tokens;
     tokens = new PRTokeniser(new RandomAccessFileOrArray(new RandomAccessSourceFactory().CreateSource(b)));
     try {
         int[] address = new int[n];
         int[] objNumber = new int[n];
         bool ok = true;
         for (int k = 0; k < n; ++k) {
             ok = tokens.NextToken();
             if (!ok)
                 break;
             if (tokens.TokenType != PRTokeniser.TokType.NUMBER) {
                 ok = false;
                 break;
             }
             objNumber[k] = tokens.IntValue;
             ok = tokens.NextToken();
             if (!ok)
                 break;
             if (tokens.TokenType != PRTokeniser.TokType.NUMBER) {
                 ok = false;
                 break;
             }
             address[k] = tokens.IntValue + first;
         }
         if (!ok)
             throw new InvalidPdfException(MessageLocalization.GetComposedMessage("error.reading.objstm"));
         for (int k = 0; k < n; ++k) {
             if (map.ContainsKey(k)) {
                 tokens.Seek(address[k]);
                 tokens.NextToken();
                 PdfObject obj;
                 if (tokens.TokenType == PRTokeniser.TokType.NUMBER) {
             	    obj = new PdfNumber(tokens.StringValue);
                 }
                 else {
             	    tokens.Seek(address[k]);
             	    obj = ReadPRObject();
                 }
                 xrefObj[objNumber[k]] = obj;
             }
         }            
     }
     finally {
         tokens = saveTokens;
     }
 }
开发者ID:,项目名称:,代码行数:51,代码来源:



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# pdf.PRTokeniser类代码示例发布时间:2022-05-26
下一篇:
C# pdf.PRIndirectReference类代码示例发布时间: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