Articles in this section
Category / Section

How to split large PDF document into multiple different ranges.

2 mins read

 

We can split the PDF document into multiple different ranges by importing pages into the new document based on the specified range. Please find the code snippet and sample link below.

// Sets the different ranges to split the PDF document.
int[] SplitArray = new int[] { 3, 5, 4 };
 
// Loads the document.
PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf");
int startIndex = 0;
int endIndex= 0;
for (int i = 0; i < SplitArray.Length; i++)
{
    endIndex += SplitArray[i];

    // Creates a new PDF document.
    PdfDocument doc = new PdfDocument();

    // Imports the pages into the new PDF document.
    doc.ImportPageRange(ldoc, startIndex, endIndex - 1);

    startIndex = endIndex;

    // Saves the document.
    doc.Save(i.ToString() + ".pdf");

    // Closes the document.
    doc.Close(true);
}

ldoc.Close(true);

 

Sample link:

https://www.syncfusion.com/downloads/support/directtrac/general/ze/PdfSample467452251-1211391395.zip

 

Note:

Starting with v16.2.0.x, if you reference Syncfusion&reg; assemblies from a trial setup or from the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion&reg; license key in your application to use the components without a trial message.

 

Conclusion

I hope you enjoyed learning about How to split large PDF document into multiple different ranges..

You can refer to our PDF feature tour page to learn about its other groundbreaking feature representations. You can also explore our documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied