Extract Content in Python

Aspose.Words - Extract Content

Python Code

## Load in the document

doc = self.Document(self.dataDir + "TestFile.doc")
\# Gather the nodes. The GetChild method uses 0-based index
startPara = doc.getFirstSection().getChild(self.NodeType.PARAGRAPH, 6, True)
endPara = doc.getFirstSection().getChild(self.NodeType.PARAGRAPH, 10, True)
\# Extract the content between these nodes in the document. Include these markers in the extraction.
extractedNodes = self.extractContents(startPara, endPara, True)
\# Insert the content into a new separate document and save it to disk.
dstDoc = self.generateDocument(doc, extractedNodes)
dstDoc.save(self.dataDir + "TestFile.Paragraphs Out.doc")

Download Running Code

Download Extract Content (Aspose.Words) from any of the below mentioned social coding sites: