Swift Package Index



A library / executable for separating PDF pages into multiple smaller files.


Build Status

A command line tool for separating the pages of a PDF file into multiple smaller files. The underlying API is also available, should you want to include it in your development projects.


$ docslice ~/Desktop/Filename.pdf -s 2

Man Page

USAGE: docslice [--output <output>] [--slices <slices>] <file>

  <file>                  A local PDF file. 

  -o, --output <output>   The destination folder for output. (default: current dir))
  -s, --slices <slices>   The number of parts the document should be evenly split into. (default: 1)
  -h, --help              Show help information.

Slice API

import Files // github.com:JohnSundell/Files

let output = Folder.home
let file = File(path: "~/myfile.pdf")
let slice = Slice(file: file, slices: 2, output: output)
try slice.run()


Install Swift (at least version 5.3) then run the following commands.

$ git clone https://github.com/nashysolutions/DocSlice.git
$ cd DocSlice
$ swift build -c release
$ cd .build/release
$ cp -f docslice /usr/local/bin/docslice

If you have any issues with unix directories this article might be helpful.

Adding underlying Slice API as a Dependency

let package = Package(
    platforms: [
    dependencies: [
        .package(name: "DocSlice", url: "https://github.com/nashysolutions/DocSlice.git", .upToNextMinor(from: "1.0.0"))
    targets: [
            name: "MyTool", 
            dependencies: [
                .product(name: "Slice", package: "DocSlice")