Skip to content

Commit

Permalink
830751 Added Split method sample project
Browse files Browse the repository at this point in the history
  • Loading branch information
sameerkhan001 committed Jun 8, 2023
1 parent 9a78e92 commit 0f807bd
Show file tree
Hide file tree
Showing 18 changed files with 399 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33516.290
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Split-PDF-based-Bookmarks", "Split-PDF-based-Bookmarks\Split-PDF-based-Bookmarks.csproj", "{7E6F40AD-CDFB-441F-B0F7-7FE483097A8F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7E6F40AD-CDFB-441F-B0F7-7FE483097A8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7E6F40AD-CDFB-441F-B0F7-7FE483097A8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7E6F40AD-CDFB-441F-B0F7-7FE483097A8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7E6F40AD-CDFB-441F-B0F7-7FE483097A8F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7C703CC3-ED5B-4D56-99D1-2A1324B00E2F}
EndGlobalSection
EndGlobal
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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))
{
PdfBookmarkBase bookmarks = loadedDocument.Bookmarks;
// Iterate all the bookmarks and their page ranges
foreach (PdfBookmark bookmark in bookmarks)
{
if (bookmark.Destination != null)
{
if (bookmark.Destination.Page != null)
{
int endIndex = bookmark.Destination.PageIndex;
int count = 0;
// Create a new PDF document
using (PdfDocument document = new PdfDocument())
{
foreach (PdfLoadedBookmark childBookmark in bookmark)
{
endIndex = childBookmark.Destination.PageIndex;
}
// Import the pages to the new PDF document
document.ImportPageRange(loadedDocument, bookmark.Destination.PageIndex, endIndex);
//Save the document as stream
using (FileStream stream = new FileStream(bookmark.Title +".pdf",FileMode.CreateNew,FileAccess.Write))
{
document.Save(stream);
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Split_PDF_based_Bookmarks</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="21.2.9" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33516.290
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Split-a-Range-of-Pages", "Split-a-Range-of-Pages\Split-a-Range-of-Pages.csproj", "{D75CD942-4DAC-400C-9AC9-89DF311C74F8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D75CD942-4DAC-400C-9AC9-89DF311C74F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D75CD942-4DAC-400C-9AC9-89DF311C74F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D75CD942-4DAC-400C-9AC9-89DF311C74F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D75CD942-4DAC-400C-9AC9-89DF311C74F8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4EBA31EB-5D7B-4EA7-B41D-6B862C6E07CE}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Syncfusion.Pdf.Parsing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Split_a_Range_of_Pages
{
internal class Program
{
static void Main(string[] args)
{

int[,] values = new int[,] { { 2, 5 }, { 8, 10 } };
//Load document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("../../Input.pdf");

//Sets pattern.
const string destinationFilePattern = "Output" + "{0}.pdf";

//Split the pages into fixed number.
loadedDocument.SplitByRanges(destinationFilePattern, values);
//close the document
loadedDocument.Close(true);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Split-a-Range-of-Pages")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Split-a-Range-of-Pages")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("d75cd942-4dac-400c-9ac9-89df311c74f8")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D75CD942-4DAC-400C-9AC9-89DF311C74F8}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Split_a_Range_of_Pages</RootNamespace>
<AssemblyName>Split-a-Range-of-Pages</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Syncfusion.Compression.Base, Version=21.2460.9.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.Compression.Base.21.2.9\lib\net46\Syncfusion.Compression.Base.dll</HintPath>
</Reference>
<Reference Include="Syncfusion.Licensing, Version=21.2460.9.0, Culture=neutral, PublicKeyToken=632609b4d040f6b4, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.Licensing.21.2.9\lib\net46\Syncfusion.Licensing.dll</HintPath>
</Reference>
<Reference Include="Syncfusion.Pdf.Base, Version=21.2460.9.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.Pdf.WinForms.21.2.9\lib\net46\Syncfusion.Pdf.Base.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Syncfusion.Compression.Base" version="21.2.9" targetFramework="net472" />
<package id="Syncfusion.Licensing" version="21.2.9" targetFramework="net472" />
<package id="Syncfusion.Pdf.WinForms" version="21.2.9" targetFramework="net472" />
</packages>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33516.290
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Split-by-FixedNumber", "Split-by-FixedNumber\Split-by-FixedNumber.csproj", "{ECC2DB3E-6A23-4000-941D-A5784A648DB1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{ECC2DB3E-6A23-4000-941D-A5784A648DB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ECC2DB3E-6A23-4000-941D-A5784A648DB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ECC2DB3E-6A23-4000-941D-A5784A648DB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ECC2DB3E-6A23-4000-941D-A5784A648DB1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {418CE45F-675D-4E05-8F8C-04A791C5720A}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Syncfusion.Pdf.Parsing;

namespace Split_by_FixedNumber
{
internal class Program
{
static void Main(string[] args)
{
//Load document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("../../Input.pdf");

//Sets pattern.
const string destinationFilePattern = "Output" + "{0}.pdf";

//Split the pages into fixed number.
loadedDocument.SplitByFixedNumber(destinationFilePattern, 4);

//close the document
loadedDocument.Close(true);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Split-by-FixedNumber")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Split-by-FixedNumber")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ecc2db3e-6a23-4000-941d-a5784a648db1")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading

0 comments on commit 0f807bd

Please sign in to comment.