ExtractPages

ExtractPages(string, string, int, int)

Extracts a specified range of pages from a document file and saves the extracted pages to a new file. The output file format is determined by the extension of the output file name.

public static void ExtractPages(string inputFileName, string outputFileName, int startPageIndex, 
    int pageCount)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
startPageIndexInt32The zero-based index of the first page to extract.
pageCountInt32Number of pages to be extracted.

Examples

Shows how to extract pages from the document.

// There is a several ways to extract pages from the document:
string doc = MyDir + "Big document.docx";

Splitter.ExtractPages(doc, ArtifactsDir + "LowCode.ExtractPages.1.docx", 0, 2);
Splitter.ExtractPages(doc, ArtifactsDir + "LowCode.ExtractPages.2.docx", SaveFormat.Docx, 0, 2);

See Also


ExtractPages(string, string, SaveFormat, int, int)

Extracts a specified range of pages from a document file and saves the extracted pages to a new file using the specified save format.

public static void ExtractPages(string inputFileName, string outputFileName, SaveFormat saveFormat, 
    int startPageIndex, int pageCount)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
saveFormatSaveFormatThe save format.
startPageIndexInt32The zero-based index of the first page to extract.
pageCountInt32Number of pages to be extracted.

Examples

Shows how to extract pages from the document.

// There is a several ways to extract pages from the document:
string doc = MyDir + "Big document.docx";

Splitter.ExtractPages(doc, ArtifactsDir + "LowCode.ExtractPages.1.docx", 0, 2);
Splitter.ExtractPages(doc, ArtifactsDir + "LowCode.ExtractPages.2.docx", SaveFormat.Docx, 0, 2);

See Also


ExtractPages(Stream, Stream, SaveFormat, int, int)

Extracts a specified range of pages from a document stream and saves the extracted pages to an output stream using the specified save format.

public static void ExtractPages(Stream inputStream, Stream outputStream, SaveFormat saveFormat, 
    int startPageIndex, int pageCount)
ParameterTypeDescription
inputStreamStreamThe input stream.
outputStreamStreamThe output stream.
saveFormatSaveFormatThe save format.
startPageIndexInt32The zero-based index of the first page to extract.
pageCountInt32Number of pages to be extracted.

Examples

Shows how to extract pages from the document from the stream.

using (FileStream streamIn = new FileStream(MyDir + "Big document.docx", FileMode.Open, FileAccess.Read))
{
    using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.ExtractPagesStream.docx", FileMode.Create, FileAccess.ReadWrite))
        Splitter.ExtractPages(streamIn, streamOut, SaveFormat.Docx, 0, 2);
}

See Also