We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to take the full width of a word page using a word-table, it should not matter wether it is landscape or portrait ?!

Thread ID:

Created:

Updated:

Platform:

Replies:

124999 Jul 13,2016 07:25 AM Jul 19,2016 07:19 AM ASP.NET MVC 6
loading
Tags: DocIO
New Tester
Asked On July 13, 2016 07:25 AM

How to take the full width of a word page using a word-table, it should not matter wether it is landscape or portrait ?!

Priyanga Elangovan [Syncfusion]
Replied On July 14, 2016 03:20 AM

Hi Customer,

Thank you for contacting Syncfusion support.

Yes, you can retrieve the full width of
a page for each section using PageSize property of WPageSetup class in DocIO.  
Kindly refer the below code snippet to retrieve the page width using a Word Table. 
//creates the document 
WordDocument document = new WordDocument(); 
document.EnsureMinimal(); 
//Adds the table to the document 
WTable table = document.LastSection.AddTable() as WTable; 
table.ResetCells(4, 4); 
//Gets the owner section of table using GetOwnerSection method 
WSection section = GetOwnerSection(table); 
//Retrieve the page width by using pagesize property 
float pagewidth = section.PageSetup.PageSize.Width; 
 
//Gets the owner section of the table: 
Private WSection GetOwnerSection(WTable table) 
{ 
//Gets the owner of the table 
Entity entity = table.Owner; 
while (!(entity is WSection)) 
{ 
if (entity.Owner != null) 
entity = entity.Owner; 
else 
break; 
} 
return entity as WSection 
} 


If we misunderstood your requirement, kindly elaborate your requirement with clear description (like screenshot of your output or expected output document), Thereby we will analyze further on your requirement and update you appropriate solution at the earliest.

Please let us know if you have any other queries.

Regards,
Priyanga.E
 


New Tester
Replied On July 15, 2016 02:36 AM

Thank you, for your answer, but I want the word table to have the same size as the page with, so that that the table will use the entire width(horizontal and vertically pages) and it should look good(the proportions of the cells).


Ayswarya Krishna Kumar [Syncfusion]
Replied On July 18, 2016 07:00 AM

Hi Customer,

Thank you for your update.

Yes, it is possible to have the Word table as of same size of its page width. Kindly use the below code snippet to achieve your requirement.

 
//Retrieve the page client area width by using page setup property  
float pageClientWidth = section.PageSetup.ClientWidth; 
//Iterating through each cells and setting up width 
//in order to fit the table 
foreach (WTableRow row in table.Rows) 
{ 
foreach (WTableCell cell in row.Cells) 
{ 
//Updates the cell width based on the page client area width 
cell.Width = pageClientWidth / row.Cells.Count; 
} 
} 
Note: Page client width excludes page margins (left and right) where as page width includes the complete width.

Regards,
Ayswarya


New Tester
Replied On July 18, 2016 07:31 AM

My table has the following declaration "IWTable table = section.AddTable();" , can you adjust your example for this `??

New Tester
Replied On July 18, 2016 07:32 AM

"table[y, x]" maybe over indexers ?!

Priyanga Elangovan [Syncfusion]
Replied On July 19, 2016 07:19 AM

Hi Customer

Thank you for your update

We have prepared the sample to meet your requirement. Please find the sample from below link. Try running the sample and let us know whether it helps you.
Sample link:
http://www.syncfusion.com/downloads/support/forum/124999/ze/SampleTable1-1888733693.zip

Regards,
Priyanga.E
 
  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;