This is a migrated thread and some comments may be shown as answers.
Center Imported Image in Table Cell
3 Answers 4 Views
This is a migrated thread and some comments may be shown as answers.
Claude
Top achievements
Rank 1
Claude asked on 07 Jan 2021, 06:53 PM

I am placing a image in a table cell and below the image I will be adding 1 to 3 lines of text.   I have it all working, but have 2 questions.

 

1.  I would like to center the image vertically in the table cell.

 

2. I want to single space the inserted text (paragraph) 

 

Below is my code:

 using (Stream firstImage = File.OpenRead(outputFileName))
                            {
                                var inImage = table1.Rows[x].Cells[y].Blocks.AddParagraph().Inlines.AddImageInline();

                                inImage.Image.Size = new System.Windows.Size(colWidth, colWidth);

                                inImage.Image.LockAspectRatio = true;
                                inImage.Image.ImageSource = new Telerik.Windows.Documents.Media.ImageSource(firstImage, "jpg");
                            }
                            table1.Rows[x].Cells[y].Blocks.AddParagraph().Inlines.AddRun(Path.GetFileNameWithoutExtension(h.fileName)); // filename

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 08 Jan 2021, 09:22 AM

Hello Claude,

1. You can set the alignment of the entire cell: 

table1.Rows[1].Cells[1].VerticalAlignment = Telerik.Windows.Documents.Flow.Model.Styles.VerticalAlignment.Center;

2. I am not sure what you are asking for. If you want to add space between the image and the text you can set the SpacingBefore property: 

var paragraph = table1.Rows[1].Cells[1].Blocks.AddParagraph();
paragraph.Inlines.AddRun("FileName");
paragraph.Spacing.SpacingBefore = 50;

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Claude
Top achievements
Rank 1
answered on 08 Jan 2021, 05:52 PM

This does center the image as desired in the Word Document, but is not transferred to the pdf document.  In pdf, the image shows on the top of the cell.

 

On the spacing, I want single spacing when adding AddParagraph.  

0
Dimitar
Telerik team
answered on 12 Jan 2021, 07:43 AM

Hi Claude,

The vertical alignment is not supported in the PDF export. We have a feature request for this on our feedback portal. You can track its progress, subscribe to status changes, and add your comment to it here: PdfProcessing: Support vertical alignment of table cells.

Unfortunately, I cannot suggest a workaround for this.

As to the spacing at hand, you can add an empty paragraph or use the SpacingBefore/SpacingAfter properties of the paragraph. 

Please let me know if there is anything else I can help you with. 

Regards,
Dimitar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Asked by
Claude
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Claude
Top achievements
Rank 1
Share this question
or