iTextSharp.text.pdf.codec.JBIG2SegmentReader.JBIG2Page.GetData C# (CSharp) Метод

GetData() публичный Метод

public GetData ( bool for_embedding ) : byte[]
for_embedding bool
Результат byte[]
            public byte[] GetData(bool for_embedding) {
                MemoryStream os = new MemoryStream();
                foreach (int sn in segs.Keys) {
                    JBIG2Segment s = (JBIG2Segment)segs[sn];

                    // pdf reference 1.4, section 3.3.6 JBIG2Decode Filter
                    // D.3 Embedded organisation
                    if ( for_embedding && 
                            ( s.type == END_OF_FILE || s.type == END_OF_PAGE ) ) {
                        continue;
                    }

                    if ( for_embedding ) {
                        // change the page association to page 1
                        byte[] headerData_emb = CopyByteArray(s.headerData);
                        if ( s.page_association_size ) {
                            headerData_emb[s.page_association_offset] = 0x0;
                            headerData_emb[s.page_association_offset+1] = 0x0;
                            headerData_emb[s.page_association_offset+2] = 0x0;
                            headerData_emb[s.page_association_offset+3] = 0x1;
                        } else {
                            headerData_emb[s.page_association_offset] = 0x1;
                        }
                        os.Write(headerData_emb, 0, headerData_emb.Length);
                    } else {
                        os.Write(s.headerData, 0, s.headerData.Length);
                    }
                    os.Write(s.data, 0, s.data.Length);
                }
                os.Close();
                return os.ToArray();
            }
            public void AddSegment(JBIG2Segment s) {

Usage Example

Пример #1
0
        /**
         * returns an Image representing the given page.
         * @param ra    the file or array containing the image
         * @param page  the page number of the image
         * @return  an Image object
         */
        public static Image GetJbig2Image(RandomAccessFileOrArray ra, int page)
        {
            if (page < 1)
            {
                throw new ArgumentException(MessageLocalization.GetComposedMessage("the.page.number.must.be.gt.eq.1"));
            }

            JBIG2SegmentReader sr = new JBIG2SegmentReader(ra);

            sr.Read();
            JBIG2SegmentReader.JBIG2Page p = sr.GetPage(page);
            Image img = new ImgJBIG2(p.pageBitmapWidth, p.pageBitmapHeight, p.GetData(true), sr.GetGlobal(true));

            return(img);
        }
All Usage Examples Of iTextSharp.text.pdf.codec.JBIG2SegmentReader.JBIG2Page::GetData
JBIG2SegmentReader.JBIG2Page