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); } }
/// <summary> /// Copy constructor used during layout expansion and page break handling. /// </summary> public PhotoLayout(PhotoLayout src) : base(src) { _photo = src._photo; _maxPhotoSize = src._maxPhotoSize; _style = src._style; }
private void AddPhoto(Photo photo, string caption) { PhotoLayout photoLayout = new PhotoLayout( photo, _maxPhotoSize, _style, _generator, _trackingInfo.LineNumber, _trackingInfo.LinePosition); TextLayout captionLayout = new TextLayout(caption, _style.CaptionStyle, _generator, _trackingInfo.LineNumber, _trackingInfo.LinePosition); _photos.Add(new CompositePhotoLayout(photoLayout, captionLayout)); }
public void AddPhoto(PhotoLayout photoLayout, TextLayout captionLayout) { TableCellLayout outer = new TableCellLayout(_generator, _trackingInfo.LineNumber, _trackingInfo.LinePosition, null); _photoRow.AddSubLayout(outer); outer.AddSubLayout(photoLayout); outer = new TableCellLayout(_generator, _trackingInfo.LineNumber, _trackingInfo.LinePosition, null); _captionRow.AddSubLayout(outer); outer.AddSubLayout(captionLayout); ++_numPhotos; }
private void RenderPhotoRowLayout(PhotoRowLayout layout, Page page) { for (int x = 0; x < layout.NumPhotos; ++x) { // There's always a photo... PhotoLayout photoCell = (PhotoLayout)layout.PhotoRow.GetSubLayoutAtIndex(x).GetSubLayoutAtIndex(0); RenderPhotoLayout(photoCell, page); // but not always a caption TableCellLayout captionCell = (TableCellLayout)layout.CaptionRow.GetSubLayoutAtIndex(x); if (captionCell.NumSubLayouts > 0) { TextLayout caption = (TextLayout)captionCell.GetSubLayoutAtIndex(0); RenderTextLayout(caption, page); } } }
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); }
private void RenderPhotoLayout(PhotoLayout layout, Page page) { Demon.PDF.Rectangle bounds = Convert.Rectangle(layout.PhotoBounds); // bounds of the photo within the layout page.AddImage(layout.PhotoData.Size, layout.PhotoData.RawData, 8, bounds); }
public CompositePhotoLayout(PhotoLayout photoLayout) { PhotoLayout = photoLayout; }
public CompositePhotoLayout(PhotoLayout photoLayout, TextLayout captionLayout) { PhotoLayout = photoLayout; CaptionLayout = captionLayout; }