Free Support Forum - groupdocs.com

Split document and get output as stream in Java

Hi, I use groupdocs-merger-19.12.jar. split() methed to split document ,how can I get each document stream after split. Thanks very much ! ! !

@YvanZhang,

We are investigating this. Your investigation ticket ID is MERGERNET-816. As there is any update, we’ll notify you.

@atirtahir3

sir,Is there any progress ,I am waiting for your good news。

1 Like

@YvanZhang,

We hope that the below code will help:

using System.Collections.Generic; 
using System.IO; 
using GroupDocs.Merger.Domain.Common; 
using GroupDocs.Merger.Domain.Options; 
public class SplitExamples 
{ 
	public List<Stream> GetSplitStreams() 
	{ 
		List<Stream> resultStreams = new List<Stream>(); 
		CreateSplitStream createSplitSream = (i) => 
		{ 
			return new MemoryStream(); 
		}; 
		ReleaseSplitStream releaseSplitStream = (i, stream) => { resultStreams.Add(stream); }; 
		SplitOptions splitOptions = new SplitOptions(createSplitSream, releaseSplitStream, new int[] { 3, 4 }, SplitMode.Pages); 
		string filePath = @"c:\sample.docx"; 
		using (GroupDocs.Merger.Merger merger = new GroupDocs.Merger.Merger(filePath)) 
		{ 
			merger.Split(splitOptions); 
		} 
		return resultStreams; 
	} 
}

@atirtahir3
Thank you for your reply. Can you provide the java version?Because I use Java to develop, I do n’t know how to translate this into Java。

1 Like

@YvanZhang,

Please download Java code here.zip (822 Bytes).
.