PdfMetamorphosisSplitPDFFileToPDFFolder Method |
Splits PDF document by pages
Namespace: SautinSoftAssembly: PdfMetamorphosis (in PdfMetamorphosis.dll) Version: 2024.12.3
Syntax public int SplitPDFFileToPDFFolder(
string SourceFile,
string OutputPath
)
Public Function SplitPDFFileToPDFFolder (
SourceFile As String,
OutputPath As String
) As Integer
Parameters
- SourceFile String
- Path to PDF file which you want to split by pages
- OutputPath String
- Path to directory where to store each PDF page as single file after splitting
Return Value
Int320 - split successfully
2 - error, output directory doesn't exist
Example How to split and merge PDF documents using C#
using System;
using System.IO;
using System.Collections;
namespace Sample
{
class Test
{
static void Main(string[] args)
{
SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();
string rtfPath = @"..\..\..\example.rtf";
string pdfPath = @"..\..\..\test.pdf";
p.PageSettings.Orientation = SautinSoft.PdfMetamorphosis.PageSetting.Orientations.Landscape;
p.PageSettings.Numbering.Text = "{page} of {numpages}";
p.PageSettings.Numbering.FontFace = "Verdana";
p.PageSettings.Numbering.FontSize = 18;
p.RtfToPdfConvertFile(rtfPath, pdfPath);
#region split PDF file
p.SplitPDFFileToPDFFolder(pdfPath, Path.GetDirectoryName(pdfPath));
#endregion
#region merge PDF files
string[] pdfFiles = { @"..\..\..\test-00001.pdf", @"..\..\..\test-00003.pdf" };
p.MergePDFFileArrayToPDFFile(pdfFiles, @"..\..\..\test_Split_and_Merge_1and3page.pdf");
#endregion
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(@"..\..\..\test_Split_and_Merge_1and3page.pdf") { UseShellExecute = true });
}
}
}
How to split and merge PDF documents using VB.Net
Imports System.IO
Module sample
Sub Main()
Dim p As New SautinSoft.PdfMetamorphosis()
Dim rtfPath As String = "..\..\..\example.rtf"
Dim pdfPath As String = "..\..\..\test.pdf"
p.PageSettings.Orientation = SautinSoft.PdfMetamorphosis.PageSetting.Orientations.Landscape
p.PageSettings.Numbering.Text = "{page} of {numpages}"
p.PageSettings.Numbering.FontFace = "Verdana"
p.PageSettings.Numbering.FontSize = 18
p.RtfToPdfConvertFile(rtfPath, pdfPath)
p.SplitPDFFileToPDFFolder(pdfPath, Path.GetDirectoryName(pdfPath))
Dim pdfFiles() As String = {"..\..\..\test-00001.pdf", "..\..\..\test-00003.pdf"}
p.MergePDFFileArrayToPDFFile(pdfFiles, "..\..\..\test_Split_and_Merge_1and3page.pdf")
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo("..\..\..\test_Split_and_Merge_1and3page.pdf") With {.UseShellExecute = True})
End Sub
End Module
See Also