Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
Question:I need to split a pdf file based on the page range using c# or VB.Net. For example, I have a 10 paged pdf file and I need to split the pages from 1-5 into a separate pdf and 5-10 pages into another separate pdf. Can any one help me out? Thanks in advance. Answer:The following code example demonstrates how to split a single PDF document Code:
public void SplitDocument()
{
//Initialize the SDK library
//You have to call this function before you can call any PDF processing functions.
PdfCommon.Initialize();
//Open and load a PDF document from a file.
using (var sourceDoc = PdfDocument.Load(@"c:\test001.pdf"))
{
//Create one PDF document for pages 1-5.
using (var doc = PdfDocument.CreateNew())
{
//Import pages from source document
doc.Pages.ImportPages(sourceDoc, "1-5", 0);
//And save it to doc1.pdf
doc.Save(@"c:\doc1.pdf", SaveFlags.Incremental);
}
//Create another PDF document for pages 5-10.
using (var doc = PdfDocument.CreateNew())
{
//Also import pages
doc.Pages.ImportPages(sourceDoc, "5-10", 0);
//And save them too
doc.Save(@"c:\doc2.pdf", SaveFlags.Incremental);
}
}
//Release all resources allocated by the SDK library
PdfCommon.Release();
}
Edited by user Tuesday, January 5, 2016 3:18:56 AM(UTC)
| Reason: Not specified
|
|
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close