I want to link 3 textboxes together (like the example in attachment).
The web application is connected to a BD that fill some base information and narrative information. For narrative information, if the text is longer thant 2 first linking textboxes, the text continue on the second page in the third textboxes. I want to know if it’s possible to do that with aspose.
If not, could you tell me another alternative to do something similar. The important point is the text in the second page must take the width of the text space. I have tried with column, but I don’t know how to insert a section break at the beggining of the second page.
Thanks and have a nice day.
Thanks for your request. Unfortunately, at the moment Aspose.Words does not support linked textboxes. Your request has been linked to the appropriate issue. We will let you know once this feature is supported.
The only way I can suggest you is using text columns instead of linked textbox.
But using text columns there is no way to achieve the same behavior as with linked TextBoxes.
Thanks Andrey for the quick reply,
If I use columns, can we locate the beginning of a (2nd) page in a document to insert a section break?? In my narrative information part, I don’t know when the text will continue on the second page. So, if I can locate the beginning of the second page, I will can insert section break to put in one column.
By hoping that my question is clear(!!!)
Thank you for additional information. MS Word document is flow document and does not contain any information about its layout into lines and pages. Our Rendering Engine layouts documents into lines and pages.
But unfortunately, there is no public API, which allows you to determine where page starts or ends. Your request has been linked to the appropriate issue. You will be notified as soon as this feature is supported.
Have a nice day!!
Regarding the page columns approach, you may be able to use this if you don’t mind some extra processing.
You can use the PageNumberFinder class found on this thread here to find which page each node is on and then move the content found on the next page into a new section.
I will try to test your before the end of the week. I think that it could be nice for my problem.
Thank you for additional information.
We will wait for your answer.
Finally, I have the time to test your suggestion…
Most of the time, at the line
List <Node> secondpageNodes = finder.RetrieveAllNodesOnPage(2, true);
it returns 0 so it can’t continue the process. When it returns more than 0, it seems to work ok. I think that the problem occurs when the second page starts in the middle of a run. For me, the case that it works when the second page starts with a carriage return. Is it my PageFinder class that can be wrong???
So, I will try to find another way to solve this… If you have any suggestions about my problem, thanks tolet me know.
Have a good day
Thanks for this additional information. Yes this is a current limiation of how a flow document is set out as a node can often span across multiple pages. I am currently working on a small fix for this for another customer which which may help you in your situation.
I will inform you when it’s ready and you can give it another try.
Thanks for your help Adam and have a good week!!
Thanks for waiting.
Please find an upated version of the PageNumberFinder class on this thread here. This update includes a new method SplitNodesAcrossPages that could be useful to you.
In your case you can use this method to split the content of each page into separate sections and then simply set the second section to different page columns. Please see the code below for an example.
Document doc = new Document("Document.docx"); PageNumberFinder finder = new PageNumberFinder(doc); // Split nodes which are found across pages. finder.SplitNodesAcrossPages(true); // Change the second section (second page) to use one page column. doc.Sections.PageSetup.TextColumns.SetCount(1); doc.Save("Document Out.docx");
If you have any troubles, could you please attach your documents here for testing.
I don’t know how to tell that in English, but this word can be appropriate… Wow!!
My first tests work very well. I will test during the week with more use cases (we have 6 templates) and I will give you more feedbacks.
Thanks again for your help!!
During my tests, I found a little problem that I not found a solution… In the template, we use bullets, so when we split the text in a paragraph using a bullet, the text is well splitted, but a bullet is added at the beginning of the second page (in the paragraph). Can we remove that bullet??
Thanks for your inquiry.
Yes I did notice this as well during my testing as well as another issue with paragraph spacing of paragraphs inside cells, but I disregarded them for the time being as I thought they would be rare cases.
I have made a quick fix for this and updated the previous attachment.
If you have any further queries, please feel free to ask.
It seems to work well. I have tested with some of our templates and it’s ok.
Thanks for your help and have a nice day!!
My client ask me something that I can’t solve… If we have more than 1 more page (if we use your solution to add a new section break at the end of the first page), my client wants to have a different header. I know that I can use Header.Primary / First option, but with the section break, my second page use the “first header”.
How can I set the primary header for my second page??
Thanks for your request. I think, in this case you can try using the following code:
// Create a blank document. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Specify that we want headers and footers different for first and other pages. builder.PageSetup.DifferentFirstPageHeaderFooter = true; // Create the headers. builder.MoveToHeaderFooter(HeaderFooterType.HeaderFirst); builder.Write("Header First"); builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary); builder.Write("Header Primary"); // Create pages in the document. builder.MoveToDocumentStart(); builder.Writeln("Page1"); builder.InsertBreak(BreakType.SectionBreakNewPage); builder.PageSetup.DifferentFirstPageHeaderFooter = false; builder.Writeln("Page2"); builder.InsertBreak(BreakType.PageBreak); builder.Writeln("Page3"); builder.InsertBreak(BreakType.SectionBreakNewPage); builder.Writeln("Page4"); builder.InsertBreak(BreakType.PageBreak); builder.Writeln("Page5"); doc.Save("C:\\Temp\\out.doc");
Hope this helps.
I missed the second line in yellow. It works well.
Thanks and have a nice day!!