extract_pages method

extract_pages(index, count)

Returns the Document object representing specified range of pages.

def extract_pages(self, index: int, count: int):
    ...
ParameterTypeDescription
indexintThe zero-based index of the first page to extract.
countintNumber of pages to be extracted.

Remarks

The resulting document should look like the one in MS Word, as if we had performed ‘Print specific pages’ – the numbering, headers/footers and cross tables layout will be preserved. But due to a large number of nuances, appearing while reducing the number of pages, full match of the layout is a quiet complicated task requiring a lot of effort. Depending on the document complexity there might be slight differences in the resulting document contents layout comparing to the source document. Any feedback would be greatly appreciated.

Examples

Shows how to get specified range of pages from the document.

doc = aw.Document(file_name=MY_DIR + 'Layout entities.docx')
doc = doc.extract_pages(0, 2)
doc.save(file_name=ARTIFACTS_DIR + 'Document.ExtractPages.docx')

See Also