diff --git a/Document-Processing/PDF/PDF-Library/NET/Split-Documents.md b/Document-Processing/PDF/PDF-Library/NET/Split-Documents.md
index aeb7989f1..dbd2375e5 100644
--- a/Document-Processing/PDF/PDF-Library/NET/Split-Documents.md
+++ b/Document-Processing/PDF/PDF-Library/NET/Split-Documents.md
@@ -23,31 +23,25 @@ Refer to the following code example to split a PDF into individual pages.
{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Pages/Splitting-PDF-file-into-individual-pages/.NET/Splitting-PDF-file-into-individual-pages/Program.cs" %}
-//Due to platform limitations, Essential® PDF supports splitting a PDF file into individual pages only in Windows Forms, WPF, ASP.NET, and ASP.NET MVC platforms. However this can be achieved by using the following code snippet.
+using Syncfusion.Pdf;
+using Syncfusion.Pdf.Parsing;
//Load the PDF document
-FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
-PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream, true);
-for (int i = 0; i < loadedDocument.Pages.Count; i++)
-{
- //Creates a new document.
- PdfDocument document = new PdfDocument();
- //Imports the pages from the loaded document.
- document.ImportPage(loadedDocument, i);
-
- //Create a File stream.
- using (var outputFileStream = new FileStream("Output" + i + ".pdf", FileMode.Create, FileAccess.Write)) {
- //Save the document to stream.
- document.Save(outputFileStream);
- }
- //Close the document.
- document.Close(true);
-}
+PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
+//Set a output path
+const string destinationFilePattern = "Output" + "{0}.pdf";
+//Split the pages into separate documents
+loadedDocument.Split(destinationFilePattern);
+//Close the document
+loadedDocument.Close(true);
{% endhighlight %}
{% highlight c# tabtitle="C# [Windows-specific]" %}
+using Syncfusion.Pdf;
+using Syncfusion.Pdf.Parsing;
+
//Load the PDF document
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
//Set a output path
@@ -61,6 +55,9 @@ loadedDocument.Close(true);
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
+Imports Syncfusion.Pdf
+Imports Syncfusion.Pdf.Parsing
+
'Load the PDF document
Dim loadedDocument As New PdfLoadedDocument("Input.pdf")
'Set a output path
@@ -87,29 +84,28 @@ Refer to the following code example to split a range of pages.
{% raw %}
-//Load the existing PDF file.
-PdfLoadedDocument loadDocument = new PdfLoadedDocument(new FileStream("Input.pdf", FileMode.Open));
-//Subscribe to the document split event.
-loadDocument.DocumentSplitEvent += LoadDocument_DocumentSplitEvent;
-void LoadDocument_DocumentSplitEvent(object sender, PdfDocumentSplitEventArgs args)
-{
- //Save the resulting document.
- FileStream outputStream = new FileStream(Guid.NewGuid().ToString() + ".pdf", FileMode.CreateNew);
- args.PdfDocumentData.CopyTo(outputStream);
- outputStream.Close();
-}
-//Spit the document by ranges.
-loadDocument.SplitByRanges(new int[,] { { 0, 5 }, { 5, 10 } });
+using Syncfusion.Pdf.Parsing;
-//Close the document.
-loadDocument.Close(true);
+//Create the values.
+int[,] values = new int[,] { { 2, 5 }, { 8, 10 } };
+//Load the PDF document
+PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
+//Set a output path
+const string destinationFilePattern = "Output" + "{0}.pdf";
+//Split the pages into fixed number
+loadedDocument.SplitByRanges(destinationFilePattern, values);
+//close the document
+loadedDocument.Close(true);
{% endraw %}
{% endhighlight %}
{% highlight c# tabtitle="C# [Windows-specific]" %}
+
{% raw %}
+using Syncfusion.Pdf.Parsing;
+
//Create the values.
int[,] values = new int[,] { { 2, 5 }, { 8, 10 } };
//Load the PDF document
@@ -127,6 +123,8 @@ loadedDocument.Close(true);
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
{% raw %}
+Imports Syncfusion.Pdf.Parsing
+
'Create the values.
Dim values As Integer(,) = New Integer(,) {{2, 5},{8, 10}}
'Load the PDF document.
@@ -137,7 +135,6 @@ Const destinationFilePattern As String = "Output" + "{0}.pdf"
loadedDocument.SplitByRanges(destinationFilePattern, values)
'Close the document.
loadedDocument.Close(True)
-
{% endraw %}
{% endhighlight %}
@@ -154,27 +151,24 @@ Refer to the following code example to split by a fixed number of pages.
{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Split%20PDFs/Split-by-FixedNumber/.NET/Split-by-FixedNumber/Program.cs" %}
-//Load the existing PDF file.
-PdfLoadedDocument loadDocument = new PdfLoadedDocument(new FileStream("Input.pdf", FileMode.Open));
-//Subscribe to the document split event.
-loadDocument.DocumentSplitEvent += LoadDocument_DocumentSplitEvent;
-void LoadDocument_DocumentSplitEvent(object sender, PdfDocumentSplitEventArgs args)
-{
- //Save the resulting document.
- FileStream outputStream = new FileStream(Guid.NewGuid().ToString() + ".pdf", FileMode.CreateNew);
- args.PdfDocumentData.CopyTo(outputStream);
- outputStream.Close();
-}
-//Spit the document by a fixed number.
-loadDocument.SplitByFixedNumber(2);
+using Syncfusion.Pdf.Parsing;
-//Close the document.
-loadDocument.Close(true);
+//Load the PDF document
+PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
+//Set a output path
+const string destinationFilePattern = "Output" + "{0}.pdf";
+//Split the pages into fixed number
+loadedDocument.SplitByFixedNumber(destinationFilePattern, 4);
+
+//close the document
+loadedDocument.Close(true);
{% endhighlight %}
{% highlight c# tabtitle="C# [Windows-specific]" %}
+using Syncfusion.Pdf.Parsing;
+
//Load the PDF document
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
//Set a output path
@@ -189,6 +183,8 @@ loadedDocument.Close(true);
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
+Imports Syncfusion.Pdf.Parsing
+
'Load the PDF document.
Dim loadedDocument As New PdfLoadedDocument("Input.pdf")
'Set a output path
@@ -214,9 +210,12 @@ Refer to the following code example to split a PDF using bookmarks.
{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Split%20PDFs/Split-PDF-based-Bookmarks/.NET/Split-PDF-based-Bookmarks/Program.cs" %}
+using Syncfusion.Pdf.Interactive;
+using Syncfusion.Pdf.Parsing;
+using Syncfusion.Pdf;
+
// Load the PDF document
-using (FileStream fileStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read))
-using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream))
+using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"))
{
PdfBookmarkBase bookmarks = loadedDocument.Bookmarks;
// Iterate all the bookmarks and their page ranges
@@ -236,11 +235,8 @@ using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream))
}
// Import the pages to the new PDF document
document.ImportPageRange(loadedDocument, bookmark.Destination.PageIndex, endIndex);
- //Save the document as stream
- using (MemoryStream stream = new MemoryStream())
- {
- document.Save(stream);
- }
+ //Save the document
+ document.Save("Output.pdf");
}
}
}
@@ -251,6 +247,10 @@ using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream))
{% highlight c# tabtitle="C# [Windows-specific]" %}
+using Syncfusion.Pdf.Interactive;
+using Syncfusion.Pdf.Parsing;
+using Syncfusion.Pdf;
+
// Load the PDF document
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"))
{
@@ -272,7 +272,7 @@ using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"))
}
// Import the pages to the new PDF document
document.ImportPageRange(loadedDocument, bookmark.Destination.PageIndex, endIndex);
- //Save the document as stream
+ //Save the document
document.Save("Output.pdf");
}
}
@@ -284,6 +284,10 @@ using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"))
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
+Imports Syncfusion.Pdf
+Imports Syncfusion.Pdf.Parsing
+Imports Syncfusion.Pdf.Interactive
+
Using loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
Dim bookmarks As PdfBookmarkBase = loadedDocument.Bookmarks
For Each bookmark As PdfBookmark In bookmarks
@@ -315,27 +319,25 @@ The Syncfusion® PDF library enables the splitting of PDF document
{% tabs %}
{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Split%20PDFs/Remove-Unused-Resources-when-Splitting-PDF-Documents/.NET/Remove-Unused-Resources-when-Splitting-PDF-Documents/Program.cs" %}
+
{% raw %}
+using Syncfusion.Pdf;
+using Syncfusion.Pdf.Parsing;
-//Load the existing PDF file.
-PdfLoadedDocument loadDocument = new PdfLoadedDocument(new FileStream("Input.pdf", FileMode.Open));
-//Subscribe to the document split event.
-loadDocument.DocumentSplitEvent += LoadDocument_DocumentSplitEvent;
-void LoadDocument_DocumentSplitEvent(object sender, PdfDocumentSplitEventArgs args)
-{
- //Save the resulting document.
- FileStream outputStream = new FileStream(Guid.NewGuid().ToString() + ".pdf", FileMode.CreateNew);
- args.PdfDocumentData.CopyTo(outputStream);
- outputStream.Close();
-}
+//Create the values.
+int[,] values = new int[,] { { 2, 5 }, { 8, 10 } };
+//Load the PDF document.
+PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
+//Set an output file pattern.
+const string destinationFilePattern = "Output{0}.pdf";
//Create the split options object.
PdfSplitOptions splitOptions = new PdfSplitOptions();
//Enable the removal of unused resources property.
splitOptions.RemoveUnusedResources = true;
//Split the document by ranges.
-loadDocument.SplitByRanges(new int[,] { { 0, 5 }, { 5, 10 } }, splitOptions);
+loadedDocument.SplitByRanges(destinationFilePattern, values, splitOptions);
//Close the document.
-loadDocument.Close(true);
+loadedDocument.Close(true);
{% endraw %}
{% endhighlight %}
@@ -343,6 +345,9 @@ loadDocument.Close(true);
{% highlight c# tabtitle="C# [Windows-specific]" %}
{% raw %}
+using Syncfusion.Pdf;
+using Syncfusion.Pdf.Parsing;
+
//Create the values.
int[,] values = new int[,] { { 2, 5 }, { 8, 10 } };
//Load the PDF document.
@@ -364,6 +369,9 @@ loadedDocument.Close(true);
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
{% raw %}
+Imports Syncfusion.Pdf
+Imports Syncfusion.Pdf.Parsing
+
'Create the values.
Dim values As Integer(,) = New Integer(,) {{2, 5},{8, 10}}
'Load the PDF document.
@@ -379,7 +387,6 @@ loadedDocument.SplitByRanges(destinationFilePattern, values, splitOptions)
'Close the document.
loadedDocument.Close(True)
-
{% endraw %}
{% endhighlight %}
@@ -396,33 +403,31 @@ The Syncfusion® PDF library enables the splitting of PDF document
{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PDF-Examples/master/Split%20PDFs/Import-tagged-structure-when-splitting-PDF-documents/.NET/Import-tagged-structure-when-splitting-PDF-documents/Program.cs" %}
{% raw %}
+using Syncfusion.Pdf;
+using Syncfusion.Pdf.Parsing;
-//Load an existing PDF file.
-PdfLoadedDocument loadDocument = new PdfLoadedDocument(new FileStream("Input.pdf", FileMode.Open));
-//Subscribe to the document split event.
-loadDocument.DocumentSplitEvent += LoadDocument_DocumentSplitEvent;
-void LoadDocument_DocumentSplitEvent(object sender, PdfDocumentSplitEventArgs args)
-{
- //Save the resulting document.
- FileStream outputStream = new FileStream(Guid.NewGuid().ToString() + ".pdf", FileMode.CreateNew);
- args.PdfDocumentData.CopyTo(outputStream);
- outputStream.Close();
-}
+//Create the values.
+int[,] values = new int[,] { { 0, 1 }, { 1, 2 } };
+//Load the PDF document.
+PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
+//Set an output file pattern.
+const string destinationFilePattern = "Output{0}.pdf";
//Create the split options object.
PdfSplitOptions splitOptions = new PdfSplitOptions();
//Enable the Split tags property.
splitOptions.SplitTags = true;
//Split the document by ranges.
-loadDocument.SplitByRanges(new int[,] { { 0, 1 }, { 1, 2 } }, splitOptions);
+loadedDocument.SplitByRanges(destinationFilePattern, values, splitOptions);
//Close the document.
-loadDocument.Close(true);
-
+loadedDocument.Close(true);
{% endraw %}
{% endhighlight %}
{% highlight c# tabtitle="C# [Windows-specific]" %}
{% raw %}
+using Syncfusion.Pdf;
+using Syncfusion.Pdf.Parsing;
//Create the values.
int[,] values = new int[,] { { 0, 1 }, { 1, 2 } };
@@ -439,12 +444,13 @@ loadedDocument.SplitByRanges(destinationFilePattern, values, splitOptions);
//Close the document.
loadedDocument.Close(true);
-
{% endraw %}
{% endhighlight %}
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
{% raw %}
+Imports Syncfusion.Pdf
+Imports Syncfusion.Pdf.Parsing
'Create the values.
Dim values As Integer(,) = New Integer(,) {{0, 1},{1, 2}}
@@ -461,7 +467,6 @@ loadedDocument.SplitByRanges(destinationFilePattern, values, splitOptions)
'Close the document.
loadedDocument.Close(True)
-
{% endraw %}
{% endhighlight %}