Document Manipulation Features


#1

Hi

Just went through the Document Manipulation Features posted in your site...

  • Programmatically create, modify or remove sections, headers, footers, paragraphs, lists, tables, rows, cells, text, fields, form fields, bookmarks, images and other document elements.
  • Specify detailed formatting for sections, paragraphs, text, rows and cells at runtime.
  • Join or split documents, copy or move fragments between documents.
  • Insert and format complex document elements such as images, hyperlinks, fields via a higher-level programming interface.
  • Can you please provide code examples for the below mentioned features...

  • Programatically create, modify, select, remove and get the position of a specified text in a document
  • I would like to copy a fragment of text from the document and paste it below that fragment of text.. how can I do that..
  • Thanks & Regards

    mano


    #2

    The document is a tree of nodes, for example paragraphs, tables, rows, cells, runs of text. Most of the operations you can do are tree-oriented. You can easily copy any node, for example if you want a copy of a paragraph (any node in fact) inserted below a particular paragraph:

    //Lets take 1st paragraph for an example
    Paragraph para = (Paragraph)doc.GetChild(NodeType.Paragraph, 0, true);

    //Make a copy
    Paragraph newPara = para.Clone(true);

    //Insert after the reference paragraph.
    para.ParentNode.InsertAfter(newPara, para);

    Having said that, there are not many operations to deal with an arbitrary fragment of text directly. For example there is no direct way for selecting and copying text from position 10 to 20 in a document. I mean it is possible if you code it, but there is no single method that does it in the public API yet.

    If you want to deal with arbitrary fragments of text you essentially need to iterate over the nodes and work with the nodes like in an XML document. It is quite hard to marry both tree and flat-text models into one API, but we will provide more public methods to deal with arbitrary flat fragments of text in the future.