PDF Extractor SDK Explained: Split and Merge PDF Documents - ByteScout

PDF Extractor SDK Explained: Split and Merge PDF Documents

  • Home
  • /
  • Articles
  • /
  • PDF Extractor SDK Explained: Split and Merge PDF Documents

In this program, we’re going to see how we can split a document using the ByteScout SDK. We have one sample document which has a total of 11 pages. We’re going to perform a split on this file. Basically, I will copy and paste the file into the Solution Explorer Window. Make sure it is available in the output directory.

START YOUR FREE TRIAL HERE

How to Split and Merge PDF Documents

Splitting the document is very simple. We just need the instance of the documents splitter class and we have to perform the split.
DocumentSplitter splitter = new DocumentSplitter(“demo”, “demo”); we are going to pass the registration name and key here. Then we are going to split it.

Split Merge PDF

Now we need to provide the source document which is like, splitter.Split(“sample.program9.pdf”,”firstSplit.pdf”, “secondSplit.pdf”, 5);. We’re having different types of options available. If we want to provide the range of the document which needs to be split, we can provide it. If you only want to split into two pages then provide the name of the first document and then the name of the second document and the split from which this needs to happen.

Split Merge PDF File

We’re going to execute it. After execution, let’s see what it is containing. We are having the first split. It contained four pages because the split happened at page number 5 and in the second split, we’re having the seven pages. It starts from page number five. Now let’s see what we can do with providing the range to it. I want different pages like var file = splitter.Split(“sample.program9.pdf”,”1-3,4-6,7-“); then foreach (var fileName in files). Console.Writeline(fileName).

Split Merge PDF Document

After execution successfully, let’s check in the temp folder and we can see the PDF split into 3 different PDF files. In this way we did the document splitting, there is one class also available for merging the document like we’re having their document merger. If you want to use it, it’s very simple. Just create the instance DocumentMerger merger = new DocumentMerger (“demo”, “demo”); provide registration key and name. Provide a source document and destination document and we are done.

PDF Extractor Video Webinar: Split and Merge PDF File

Tutorials:

prev
next