We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

I want to insert TextBox the every page top!

my word document the first page have a textbox,I want to copy the textbox to second page,thrid page etc.
I don’t know how to do.

 but I test code ,I want to get PageIndex and I can insert every page the textbox,but I use GetStartPageIndex the builder can not writeln,why? 

            var doc = new Aspose.Words.Document("D:\test\abc.docx");
           //new  Document(
            //LayoutEnumerator en = new LayoutEnumerator(doc);
            NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);

            DocumentBuilder builder = new DocumentBuilder(doc);

            Aspose.Words.Layout.LayoutCollector layoutColler = new Aspose.Words.Layout.LayoutCollector(doc);
           for(int x = 0 ; x < 30; x++)

            foreach (Node node in doc.FirstSection.Body.GetChildNodes(NodeType.Any, true))
               builder.Writeln( layoutColler.GetStartPageIndex(node).toString());   // but this is not execute why?
          builder.Writeln("Builder End");
          builder.Document.Save("D:\test\abc.pdf", SaveFormat.Pdf);


You can simply copy the textbox in Header to make it visible across all pages in document. Please use the same technique as mentioned in following article:

How to Add a Watermark to a Document

I want to copy the first page textbox to second page,thrid page ,
and copy fourth page textbox to fifth page。
the textbox is different。


Thanks for your inquiry. To ensure a timely and accurate response, please ZIP and attach the following resources here for testing:

  • Your sample input Word document
  • Your expected Word document (DOCX file) showing the correct final output. Please create this document by using MS Word. We will investigate the structure of your expected document as to how you want your final output be generated like.

As soon as you get these pieces of information ready, we will start further investigation into your issue and provide you more information. Thanks for your cooperation.

Desktop.zip (38.4 KB)

you can suggest me how to copy title,thank you !


You can clone existing nodes (paragraphs, tables etc) and insert them at any location in Document. For example, the following code will clone the first Paragraph and inserts it at the end of Document.

Document doc = new Document(MyDir + @"Desktop\raw.docx");
Paragraph clone = (Paragraph)doc.FirstSection.Body.FirstParagraph.Clone(true);
doc.FirstSection.Body.InsertBefore(clone, doc.FirstSection.Body.LastParagraph);
doc.Save(MyDir + @"Desktop\18.5.docx");