Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 78 additions & 2 deletions File-Formats/PDF/Split-Documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ Dim loadedDocument As New PdfLoadedDocument("Input.pdf")
'Set an output path.
Const destinationFilePattern As String = "Output" + "{0}.pdf"
'Create the split options object.
Dim splitOptions As New PdfSplitOptions();
Dim splitOptions As New PdfSplitOptions()
'Enable the removal of unused resources property.
splitOptions.RemoveUnusedResources = True
'Split the document by ranges.
Expand All @@ -365,4 +365,80 @@ loadedDocument.Close(True)

{% endtabs %}

Download a complete working sample from GitHub.

Download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Split%20PDFs/Remove-Unused-Resources-when-Splitting-PDF-Documents/.NET).

## Import Tagged structure when Splitting PDF Documents

The Syncfusion PDF library enables the splitting of PDF documents and offers the capability to import tagged structure during the process. By enabling the `SplitTags` property on the `PdfSplitOptions` class, thereby tagged structure will be imported into the final PDF document. The default value for this property is false.

{% tabs %}

{% highlight c# tabtitle="C# [Cross-platform]" %}

//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 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);

//Close the document.
loadDocument.Close(true);

{% endhighlight %}

{% highlight c# tabtitle="C# [Windows-specific]" %}

//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.
loadedDocument.SplitByRanges(destinationFilePattern, values, splitOptions);

//Close the document.
loadedDocument.Close(true);

{% endhighlight %}

{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}

'Create the values.
Dim values As Integer(,) = New Integer(,) {{0, 1},{1, 2}}
'Load the PDF document.
Dim loadedDocument As New PdfLoadedDocument("Input.pdf")
'Set an output path.
Const destinationFilePattern As String = "Output" + "{0}.pdf"
'Create the split options object.
Dim splitOptions As New PdfSplitOptions()
'Enable the Split tags property.
splitOptions.SplitTags = True
'Split the document by ranges.
loadedDocument.SplitByRanges(destinationFilePattern, values, splitOptions)

'Close the document.
loadedDocument.Close(True)

{% endhighlight %}

{% endtabs %}

Download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Split%20PDFs/Import-tagged-structure-when-splitting-PDF-documents/.NET).