From 75fa927cad5964d7049428fcee138bdeea3ef37d Mon Sep 17 00:00:00 2001 From: Srihariharan Date: Fri, 22 Dec 2023 16:09:22 +0530 Subject: [PATCH 1/2] documentation Volume 4 features - Split Tags --- File-Formats/PDF/Split-Documents.md | 78 ++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/File-Formats/PDF/Split-Documents.md b/File-Formats/PDF/Split-Documents.md index 7d86b3ac2..be2717914 100644 --- a/File-Formats/PDF/Split-Documents.md +++ b/File-Formats/PDF/Split-Documents.md @@ -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). From 5f2642360a6241d624b40956753ff82bca147343 Mon Sep 17 00:00:00 2001 From: Sivaram Gunabalan Date: Fri, 22 Dec 2023 17:47:27 +0530 Subject: [PATCH 2/2] Removed semi colon --- File-Formats/PDF/Split-Documents.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/File-Formats/PDF/Split-Documents.md b/File-Formats/PDF/Split-Documents.md index be2717914..e32fcaf06 100644 --- a/File-Formats/PDF/Split-Documents.md +++ b/File-Formats/PDF/Split-Documents.md @@ -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. @@ -428,7 +428,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 Split tags property. splitOptions.SplitTags = True 'Split the document by ranges.