IN ASPOSE.WORDS THE DOC_PART_OBJ,DOC_PART_GALLERY,DOC_PART_UNIQUE ARE SUPPORTED BY ASPOSE AND GIVE EXAMPLE IMPLEMENTATION?

"rId2": [
         {
            "type": "STRUCTURED_DOCUMENT_TAG",
            "content": [
               {
                  "type": "SDT_PROPERTIES",
                  "content": [
                     {
                        "type": "DOC_PART_OBJ",
                        "content": [
                           {
                              "type": "DOC_PART_GALLERY",
                              "attributes": {
                                 "val": "PAGE NUMBERS (BOTTOM OF PAGE)"
                              }
                           },
                           {
                              "type": "DOC_PART_UNIQUE"
                           }
                        ]
                     }
                  ]
               },
               {
                  "type": "SDT_CONTENT",
                  "content": [
                     {
                        "type": "PARAGRAPH",
                        "content": [
                           {
                              "type": "PARAGRAPH_PROPERTIES",
                              "content": [
                                 {
                                    "type": "PARAGRAPH_STYLE",
                                    "attributes": {
                                       "val": "footer"
                                    }
                                 },
                                 {
                                    "type": "ALIGNMENT",
                                    "attributes": {
                                       "val": "CENTER"
                                    }
                                 }
                              ]
                           },
                           {
                              "type": "RUN",
                              "content": [
                                 {
                                    "type": "FIELD_CHARACTER",
                                    "attributes": {
                                       "fldCharType": "BEGIN"
                                    }
                                 }
                              ]
                           },
                           {
                              "type": "RUN",
                              "content": [
                                 {
                                    "type": "INSTRUCTION_TEXT",
                                    "instructionText": " PAGE   \\* MERGEFORMAT ",
                                    "attributes": {
                                       "space": "PRESERVE"
                                    }
                                 }
                              ]
                           },
                           {
                              "type": "RUN",
                              "content": [
                                 {
                                    "type": "FIELD_CHARACTER",
                                    "attributes": {
                                       "fldCharType": "SEPARATE"
                                    }
                                 }
                              ]
                           },
                           {
                              "type": "RUN",
                              "content": [
                                 {
                                    "type": "TEXT",
                                    "text": "2"
                                 }
                              ]
                           },
                           {
                              "type": "RUN",
                              "content": [
                                 {
                                    "type": "FIELD_CHARACTER",
                                    "attributes": {
                                       "fldCharType": "END"
                                    }
                                 }
                              ]
                           }
                        ]
                     }
                  ]
               }
            ]
         }
      ],

@AAddd

In Aspose.Words, the DOC_PART_OBJ, DOC_PART_GALLERY, and DOC_PART_UNIQUE types are supported as part of structured document tags (SDTs). These types allow you to create and manage content controls in Word documents effectively.

Example Implementation

Here’s a simple example demonstrating how to create a structured document tag with these types in Java using Aspose.Words:

import com.aspose.words.*;

public class StructuredDocumentTagExample {
    public static void main(String[] args) throws Exception {
        // Create a new document
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);

        // Create a structured document tag of type DOC_PART_OBJ
        StructuredDocumentTag docPartObjSdt = new StructuredDocumentTag(doc, SdtType.DOC_PART_OBJ, MarkupLevel.INLINE);
        
        // Set the building block gallery and unique identifier
        docPartObjSdt.setBuildingBlockGallery("PAGE NUMBERS (BOTTOM OF PAGE)");
        docPartObjSdt.setBuildingBlockCategory("Built-in");
        
        // Add the structured document tag to the document
        builder.insertNode(docPartObjSdt);

        // Save the document
        doc.save("StructuredDocumentTagExample.docx");
    }
}

Explanation

  • Creating a Document: A new document is created using the Document class.
  • Document Builder: The DocumentBuilder class is used to insert nodes into the document.
  • Structured Document Tag: A StructuredDocumentTag of type DOC_PART_OBJ is created. You can set its gallery and category using the appropriate methods.
  • Inserting the Tag: The structured document tag is inserted into the document using the insertNode method of the DocumentBuilder.
  • Saving the Document: Finally, the document is saved to a file.

This example illustrates how to create a structured document tag that can be used to manage content in a Word document effectively. You can further customize the properties of the structured document tag as needed.

For more detailed information, you can refer to the Aspose.Words documentation on structured document tags and their properties.

Sources