zhao
2021-07-09 0821715ebc11d3934d0594a1cc2c39686d808906
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//============================================================================
//Gios Pdf.NET - A library for exporting Pdf Documents in C#
//Copyright (C) 2005  Paolo Gios - www.paologios.com
//
//This library is free software; you can redistribute it and/or
//modify it under the terms of the GNU Lesser General Public
//License as published by the Free Software Foundation; either
//version 2.1 of the License, or (at your option) any later version.
//
//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//=============================================================================
using System;
using System.Data;
using System.Collections;
using System.Drawing;
 
namespace HH.WMS.Utils.Gios.Pdf
{
    /// <summary>
    /// 
    /// </summary>
    public class PdfTablePage : PdfObject
    {
        internal Hashtable cellAreas;
        internal int startRow,endRow,columns;
        internal string stream;
        internal PdfArea area;
        /// <summary>
        /// 
        /// </summary>
        public PdfArea Area
        {
            get
            {
                return area;
            }
        }
        internal PdfTablePage(int startRow,int endRow,int columns)
        {
            this.cellAreas=new Hashtable();
            this.startRow=startRow;
            this.endRow=endRow;
            this.columns=columns;
        }
        /// <summary>
        /// returns the Area where the Cell has been rasterized.
        /// </summary>
        /// <param name="Row"></param>
        /// <param name="Column"></param>
        /// <returns></returns>
        public PdfArea CellArea(int Row,int Column)
        {
            object o=this.cellAreas[Row+","+Column];
            if (o==null) throw new Exception("Cell ["+Row+","+Column+"] does not belong to the TablePage.");
            return o as PdfArea;
        }
        internal void SetArea()
        {
            
            this.area=this.CellArea(startRow,0).Merge(this.CellArea(endRow,0));
            double great=0;
            foreach (PdfArea pa in this.cellAreas.Values)
            {
                double d=pa.BottomRightCornerX;
                if(d>great) great=d;
            }
            this.area.BottomRightCornerX=great;
            
        }
        /// <summary>
        /// the index of the first Row of the rendered Table Page.
        /// </summary>
        public int FirstRow
        {
            get
            {
                return this.startRow;
            }
        }
        /// <summary>
        /// the index of the last Row of the rendered Table Page.
        /// </summary>
        public int LastRow
        {
            get
            {
                return this.endRow;
            }
        }
        /// <summary>
        /// returns true if the Table Contains the rendering of this Row Index.
        /// </summary>
        /// <param name="RowIndex"></param>
        /// <returns></returns>
        public bool ContainsRow(int RowIndex)
        {
            if ((this.startRow<=RowIndex)&&(RowIndex<=this.endRow)) return true;
            return false;
        }
        internal override int StreamWrite(System.IO.Stream stream)
        {
            int num=this.id;
 
            string text=this.stream;
            Byte[] part2;
                
            if (PdfDocument.FlateCompression) part2=Utility.Deflate(text); else
                part2=System.Text.ASCIIEncoding.ASCII.GetBytes(text);
 
            string s1="";
            s1+=num.ToString()+" 0 obj\n";
            s1+="<< /Lenght "+part2.Length;
            if (PdfDocument.FlateCompression) s1+=" /Filter /FlateDecode";
            s1+=">>\n";
                
            s1+="stream\n";
                
            string s3="\nendstream\n";
            s3+="endobj\n";
 
            Byte[] part1=System.Text.ASCIIEncoding.ASCII.GetBytes(s1);
            Byte[] part3=System.Text.ASCIIEncoding.ASCII.GetBytes(s3);
            stream.Write(part1,0,part1.Length);
            stream.Write(part2,0,part2.Length);
            stream.Write(part3,0,part3.Length);
            return part1.Length+part2.Length+part3.Length;
        }
 
    }
}