Hey,
I am building the document with the DocumentBuilder.
Actually I have the problem that I “pin” a Header of a Table with “HeadingFormat” but the Thing is, that one is only pinned for one page. Also I need to pin my “subcategory” wich is just a row in the table with another font-style. so I am doing the “HeadingFormat = true” for all my category row, but the first one is displayed on the second page, not as I suspected, the last one.
Is it possible to make that work?
I could not find a solution inside your documentation.
Cheers
Raphael
We are just evaluating your component. Can you please help me?
Hi Raphael,
Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:
- Your input Word document
- Please attach the output Word file that shows the undesired behavior.
- Please attach the expected output Word file that shows the desired behavior.
- Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.
As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.
PS: To attach these resources, please zip them and Click ‘Reply’ button that will bring you to the ‘reply page’ and there at the bottom you can include any attachments with that post by clicking the ‘Add/Update’ button.
Hey,
Here’s the standalone app with the two documents.
There is no input document, because its completely generated.
Hi Raphael,
Thanks for sharing the detail. You are getting the expected behavior of RowFormat.HeadingFormat. In your expected output document, you created new table at page 3.
Please note that Aspose.Words mimics the same behavior as MS Word does. If you create the same table (with repeat header rows) using MS Word, you will get the same output.
Thanks for the reply, but it is not really helpful.
I need to have the third category line to be the header on the next page. Wha can’t this property be overwritten instead of just displaying the first one? How can I get to that solution? Is it possible to find out where a pagebreak will happen to turn on the “Headingformat” just on the last one?
Cheers
Hi Raphael,
Thanks for your inquiry. In your case, we suggest you following solution.
- Insert a bookmark with name e.g “subcategory” in the subcategory row
- After creating the table, get the subcategory row using bookmark
- Iterate through all rows of table and insert new subcategory row at the start of new page
Following code example inserts a new row at the start of new page start from page 2. Hope this helps you. We have attached input and output documents with this post for your kind reference.
Document doc = new Document(MyDir + "sampleDoc.docx");
Table table = (Table)doc.FirstSection.Body.GetChild(NodeType.Table, 0, true);
// Your code to create table
Bookmark bm = doc.Range.Bookmarks["subcategory"];
Row subcategoryRow = (Row)bm.BookmarkStart.GetAncestor(NodeType.Row);
LayoutCollector collector = new LayoutCollector(doc);
int page = 2;
foreach (Row row in table.Rows)
{
if (collector.GetStartPageIndex(row) == page)
{
row.ParentNode.InsertBefore(subcategoryRow.Clone(true), row);
page++;
}
}
doc.Save(MyDir + "Out.docx");