Пример #1
0
        public BlockPage Process(BlockPage page2)
        {
            var page = page2 as BlockPage2;

            if (page == null)
            {
                PdfReaderException.AlwaysThrow("BlocksetData must execute AFTER OrganizePageLayout");
            }

            var blocksetInfo = new BlockPage2();

            foreach (var segment in page.Segments)
            {
                var segmentInfo = new BlockPageSegment(blocksetInfo, segment.NumberOfColumns);

                foreach (var column in segment.Columns)
                {
                    var columnInfo = CopyColumnMetadata(blocksetInfo, column);

                    segmentInfo.AddColumn(columnInfo);
                }

                blocksetInfo.AddSegment(segmentInfo);
            }

            this._blocksetInfo = blocksetInfo;

            return(page);
        }
Пример #2
0
        public BlockPage Process(BlockPage page)
        {
            SetupPage(page);

            BlockPage2 newpage = new BlockPage2();

            int last_columnType = -1;
            int last_columnX    = -1;
            int last_columnSize = -1;

            BlockPageSegment segment = null;
            BlockColumn      column  = null;

            foreach (var block in page.AllBlocks)
            {
                float x  = block.GetX() - _minX;
                float x2 = block.GetX() + block.GetWidth() - _minX;
                float w  = block.GetWidth();

                int columnSize = GetColumnWidth(w);
                int columnType = GetNumberOfColumns(columnSize);

                // different Page Segment
                if (columnType != last_columnType)
                {
                    segment = new BlockPageSegment(newpage, columnType);
                    newpage.AddSegment(segment);

                    //Console.WriteLine(columnType);
                    //Console.WriteLine("add new segment/column");

                    last_columnType = columnType;
                    last_columnX    = -1;
                    last_columnSize = -1;
                }

                int position = GetColumnX(x, columnType);

                if (last_columnX != position || last_columnSize != columnSize)
                {
                    //Console.WriteLine($"NEW COLUMN");
                    column = new BlockColumn(newpage, columnType, position, columnSize);
                    segment.AddColumn(column);

                    last_columnX    = position;
                    last_columnSize = columnSize;
                }

                //Console.WriteLine($"position x: {position} (ADDBLOCK)");

                column.AddBlock(block);
            }

            //Console.WriteLine($"Page type = {newpage.ToString()}");
            _pageLayout = newpage.ToString();

            return(newpage);
        }
Пример #3
0
        public BlockPage Process(BlockPage page2)
        {
            var page = page2 as BlockPage2;

            if (page == null)
            {
                PdfReaderException.AlwaysThrow("ResizeSequentialLayout must execute AFTER OrganizePageLayout");
            }

            var result = new BlockPage2();

            foreach (var segment in page.Segments)
            {
                BlockPageSegment newsegment = new BlockPageSegment(result, segment.NumberOfColumns);

                foreach (var column in segment.Columns)
                {
                    BlockColumn newcolumn = new BlockColumn(result, column.ColumnType, column.X1, column.W);

                    float minX = column.Min(b => b.GetX());
                    float maxX = column.Max(b => b.GetX() + b.GetWidth());

                    foreach (var block in column)
                    {
                        var bset = block as IBlockSet <IBlock>;

                        if (block is TableSet || block is ImageBlock)
                        {
                            newcolumn.Add(block);
                            continue;
                        }

                        if (bset == null)
                        {
                            PdfReaderException.AlwaysThrow("not expected");
                        }

                        var resizeBset = ResizeBlockSet(bset, minX, maxX);

                        newcolumn.Add(resizeBset);
                    }

                    newsegment.AddColumn(newcolumn);
                }

                result.AddSegment(newsegment);
            }

            return(result);
        }
Пример #4
0
        public BlockPage Process(BlockPage page2)
        {
            var page = page2 as BlockPage2;

            if (page == null)
            {
                PdfReaderException.AlwaysThrow("MergeSequentialLayout must execute AFTER OrganizePageLayout");
            }

            var result = new BlockPage2();

            foreach (var segment in page.Segments)
            {
                BlockPageSegment newsegment = new BlockPageSegment(result, segment.NumberOfColumns);

                foreach (var column in segment.Columns)
                {
                    BlockColumn newcolumn = new BlockColumn(result, column.ColumnType, column.X1, column.W);

                    IBlock last = null;

                    var orderedColumns = column.OrderByDescending(b => b.GetH());

                    foreach (var block in orderedColumns)
                    {
                        if (last != null)
                        {
                            var b1 = last as IBlockSet <IBlock>;
                            var b2 = block as IBlockSet <IBlock>;

                            if (block is TableSet || block is ImageBlock || last is TableSet || last is ImageBlock)
                            {
                                newcolumn.Add(last);
                                last = block;
                                continue;
                            }

                            if (b1 == null || b2 == null)
                            {
                                PdfReaderException.AlwaysThrow("not expected");
                            }

                            if (Block.SameHeight(b1, b2))
                            {
                                last = Merge(b1, b2);

                                // merge
                                continue;
                            }

                            newcolumn.Add(last);
                        }

                        last = block;
                    }

                    if (last != null)
                    {
                        newcolumn.Add(last);
                    }

                    newsegment.AddColumn(newcolumn);
                }

                result.AddSegment(newsegment);
            }

            return(result);
        }