- Home
- Forum
- ASP.NET MVC
- I want the image more centered and and the text more on the right side.
I want the image more centered and and the text more on the right side.
//Part 0 - Init
IWParagraph footerPar = new WParagraph(doc);
IWTable tablefooterPar = section.HeadersfooterPars.footerPar.AddTable();
RowFormat formatfooterPar = new RowFormat();
formatfooterPar.Borders.BorderType = BorderStyle.Single;
tablefooterPar.ResetCells(1, 2);
//Part 1 - Cell 1
footerPar = tablefooterPar[0, 0].AddParagraph() as WParagraph;
WPicture picturefooterPar = (WPicture)footerPar.AppendPicture(Image.FromFile(Path.Combine("...", "....png")));
picturefooterPar.VerticalAlignment = ShapeVerticalAlignment.Bottom;
(footerPar.Items[0] as WPicture).Width = 180.5f;
(footerPar.Items[0] as WPicture).Height = 25.75f;
//tablefooterPar[0, 0].Width = 380;
//Part 2 - Cell 2
footerPar = tablefooterPar[0, 1].AddParagraph() as WParagraph;
IWTextRange txtfooterPar = footerPar.AppendText("\nsome text\nsome text\nsome text\n\nsome text\nsome text\nsome text\nsome text");
txtfooterPar.CharacterFormat.FontSize = 15;
tablefooterPar.TableFormat.HorizontalAlignment = RowAlignment.Center;
footerPar.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Left;
(tablefooterPar[0, 1] as WTableCell).CellFormat.VerticalAlignment = VerticalAlignment.Top;
I want the image more centered and and the text more on the right side.
My requirements are:
- the text shall still have the alignment left
- I want the entire cell to be moved more to the right
- the table shall use the entire width
I tried using something like this "tablefooterPar[0, 0].Width = 380;", but this changed also the entire table.
Maybe you can give me another solution ?
Thank you for using Syncfusion products.
On further analysing with the given details we suspect anyone of the following is your requirement.
1. Create a new table with 1 row and 2 cells. In first cell, inserted image should align in centre of the cell. In second cell, appended paragraph text should align in right of the cell.
2. Table width should have equivalent to width of the page.
Kindly provide your confirmation on the mentioned cases, thereby we will analyse further and will provided you appropriate solution.
For more details kindly refer following UG Link:
https://help.syncfusion.com/file-formats/docio/working-with-tables
https://help.syncfusion.com/file-formats/docio/working-with-paragraph#working-with-images
If we misunderstand your requirement then, kindly provide us Input document used (if any) and screenshot/output Word document of the expected result which will helpful to provide you the appropriate solution
Thanks,
Sethumanikkam.Y
What you guys suggested is exactly what I'm trying to do. How do I achieve it?
I have a table and need to center the images in said table's cells, with even multiple images in a single cell.
Hi Thomas,
From the given details, we have found that your requirement is to align an
image in the center of a table cell. To achieve your requirement, we suggested
you to set vertical alignment as Middle to VerticalAlignment
API of the table cell and set horizontal alignment as Center to the HorizontalAlignment
API of the paragraph. Please refer to the below-highlighted code snippet.
|
WTableCell cell = table[0, 1]; //Specifies the vertical alignment of content of text. cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle; //Add paragraph to the table cell. paragraph = cell.AddParagraph(); //Set horizantal alignment of the paragraph. paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center; //Append picture to the paragraph. paragraph.AppendPicture(Image.FromFile(Path.GetFullPath(@"../../Images/Image1.jpg")));
|
We have prepared a sample
application that demonstrates even when multiple images are present within a
single cell how to align those images in the center of a table cell. It can be
downloaded from the below,
https://www.syncfusion.com/downloads/support/directtrac/general/ze/Align-image-in-table847705134.zip
Please refer to our below UG documentation to know more about how to work with
the table in the Word document,
https://help.syncfusion.com/file-formats/docio/working-with-tables
Refer to our below UG documentation to know more about how to work with images
in the Word document,
https://help.syncfusion.com/file-formats/docio/working-with-paragraph#working-with-images
Regards,
Anto Nihil S
- 3 Replies
- 4 Participants
-
NT New Tester
- Oct 14, 2016 05:33 AM UTC
- Jul 7, 2023 09:24 AM UTC