Exemplo n.º 1
0
        private void RenderPhotoRow(PhotoRowLayout layout, ITableRow row)
        {
            //	In the design we represent a photo row as a pair of table rows
            //	without a table: one row for the photos, and the other for the
            //	captions. This design is useful for PDF, and requires special
            //	handling of borders to make the vertical pairs of cells (photo
            //	cell and caption cell) appear as a single cell. But it's not
            //	necessary in Word because we can just add the photo and caption
            //	as two paragraphs in a single cell. So deconstruct the photo
            //	row into its pairs of cells and then render each pair as a
            //	single cell.
            for (int x = 0; x < layout.NumPhotos; ++x)
            {
                PhotoLayout photoCell   = (PhotoLayout)layout.PhotoRow.GetSubLayoutAtIndex(x).GetSubLayoutAtIndex(0);
                TextLayout  captionCell = (TextLayout)layout.CaptionRow.GetSubLayoutAtIndex(x).GetSubLayoutAtIndex(0);

                s.TableCellStyle cellStyle = null;
                if (layout.Style != null)
                {
                    s.PhotoStyle photoStyle = (s.PhotoStyle)layout.Style;
                    cellStyle = new s.TableCellStyle
                    {
                        Padding = photoStyle.Padding
                    };
                }
                ITableCell cell = row.AddCell(1, cellStyle, layout.TrackingInfo);
                RenderPhoto(photoCell, cell);
                RenderText(captionCell, cell);
            }
        }
Exemplo n.º 2
0
        private void RenderPhotoTable(PhotoTableLayout layout, IContentContainer container)
        {
            //	Create a table
            s.TableStyle tableStyle = null;
            if (layout.Style != null)
            {
                s.PhotoStyle photoStyle = (s.PhotoStyle)layout.Style;
                tableStyle = new s.TableStyle
                {
                    Border  = photoStyle.Border,
                    Padding = photoStyle.Padding
                };
            }

            int columnWidth = layout.Bounds.Width / layout.NumColumns;

            int[] columnWidths = new int[layout.NumColumns];
            for (int x = 0; x < columnWidths.Length; ++x)
            {
                columnWidths[x] = columnWidth;
            }

            ITable table = container.AddTable(layout.Bounds.Width, columnWidths, tableStyle, layout.TrackingInfo);

            //	Create a table row for each photo row
            foreach (PhotoRowLayout photoRow in layout.SubLayouts)
            {
                s.TableRowStyle rowStyle = null;
                if (photoRow.Style != null)
                {
                    s.PhotoStyle photoStyle = (s.PhotoStyle)photoRow.Style;
                    rowStyle = new s.TableRowStyle
                    {
                        BackColor = photoRow.BackgroundColor,
                        Padding   = photoStyle.Padding
                    };
                }
                ITableRow tableRow = table.AddRow(rowStyle, photoRow.TrackingInfo);
                RenderPhotoRow(photoRow, tableRow);
            }
        }
Exemplo n.º 3
0
        private void RenderPhoto(PhotoLayout layout, IContentContainer container)
        {
            //	Add the photo part to the document
            string imageId = _document.AddImage(layout.PhotoData.RawData);

            //	Add a new paragraph and insert into it a reference to the photo.
            //
            //	A photo is always in a paragraph of its own, and the photo
            //	style's border and padding etc. are rendered on the paragraph.
//TODO: I'm not sure that that statement about styles is correct

            s.TextStyle paraStyle = null;
            if (layout.Style != null)
            {
                s.PhotoStyle photoStyle = (s.PhotoStyle)layout.Style;
                paraStyle         = new s.TextStyle();
                paraStyle.Border  = photoStyle.Border;
                paraStyle.Padding = photoStyle.Padding;
            }
            IParagraph paragraph = container.AddParagraph(paraStyle, layout.TrackingInfo);

            paragraph.AddImage(imageId, layout.Bounds.Width, layout.Bounds.Height);
        }