Created
October 19, 2021 17:08
-
-
Save GroupDocsGists/4a46dd994d515ad491f5bcdcf6ec11d6 to your computer and use it in GitHub Desktop.
Ways to Split PDF file into Multiple files and Pages using C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Split PDF file by Given Range into Single Page files using C# | |
*/ | |
// Define output file(s) format | |
string filePathOut = "path/splitPDF_{0}.{1}"; | |
// Define Range to extract as single page documents | |
SplitOptions splitOptions = new SplitOptions(filePathOut, 3, 7); | |
// Load the PDF file & Split PDF according to split options | |
using (Merger merger = new Merger("path/document.pdf")) | |
{ | |
merger.Split(splitOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Split PDF file by Given Range & Filter (Even/Odd Pages) into Single Page files using C# | |
*/ | |
// Define output file(s) format | |
string filePathOut = "path/splitPDF_{0}.{1}"; | |
// Define Range & Filter to extract all the ODD Pages in the given Range as single page documents | |
SplitOptions splitOptions = new SplitOptions(filePathOut, 3, 7, RangeMode.OddPages); | |
// Load the PDF file & Split PDF according to split options | |
using (Merger merger = new Merger("path/document.pdf")) | |
{ | |
merger.Split(splitOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Split PDF files into multipage files using C# | |
*/ | |
// Define output file(s) format | |
string filePathOut = "path/splitPDF_{0}.{1}"; | |
// Define Splitting Intervals and Split Mode | |
SplitOptions splitOptions = new SplitOptions(filePathOut, new int[] { 3, 6, 8 }, SplitMode.Interval); | |
// Load the PDF file & Split PDF according to split options | |
using (Merger merger = new Merger("path/document.pdf")) | |
{ | |
merger.Split(splitOptions); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Split PDF file into Single Page files using C# | |
*/ | |
// Define output file(s) format | |
string filePathOut = "path/splitPDF_{0}.{1}"; | |
// Define pages to get extracted as single page document | |
SplitOptions splitOptions = new SplitOptions(filePathOut, new int[] { 3, 6, 8 }); | |
// Load the PDF file & Split PDF according to split options | |
using (Merger merger = new Merger("path/document.pdf")) | |
{ | |
merger.Split(splitOptions); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment