How can I split up a PDF file into pages (preferably C#)
Asked Answered
I

5

17

My client has a multi-page PDF file. They need it split by page. Does anyone know of a way to do this - preferably in C#.

Immerse answered 23/9, 2008 at 16:26 Comment(0)
U
17

PDFSharp is an open source library which may be what you're after:

Key Features

  • Creates PDF documents on the fly from any .Net language
  • Easy to understand object model to compose documents
  • One source code for drawing on a PDF page as well as in a window or on the printer
  • Modify, merge, and split existing PDF files

This sample shows how to convert a PDF document with n pages into n documents with one page each.

Unhitch answered 23/9, 2008 at 16:29 Comment(0)
T
4

I did this using ITextSharp -- there are commercial options that may have a good API but this is open source and free, and not hard to use.

Check out this code, it's one of their code samples -- it's pretty good. It splits a PDF file into two files at the passed-in page number. You can modify it to loop and split page by page.

Theophilus answered 23/9, 2008 at 16:31 Comment(1)
iTextSharp is no more free to use in commerical applications. It is currently released under AGPL license. Ghostscript can split a pdf. "gs -q -dBATCH -dNOPAUSE -sOutputFile=page{page:04d}.pdf" " -dFirstPage={page} -dLastPage={page}" " -sDEVICE=pdfwrite {input_pdf}"Althorn
N
2

Haven't played with it, but you can look at Aspose.Pdf.Kit for .NET and Java. It is commercial so you'll need to pay licensing feeds, but if you need commercial support it might work for you.

Necker answered 23/9, 2008 at 18:0 Comment(0)
P
2

Siberix offers a reasonably costed commercial library for creating PDF's on the fly in .NET: http://siberix.com You can create the PDF's programmatically or through an XML transformation (and a combination of both IIRC).

I've used their library on a couple of projects and have found that not only is their library easy to work with, but their email support is incredible. And the license is quite cheap as well.

Pennington answered 23/9, 2008 at 23:0 Comment(0)
P
0

SautinSoft.Pdf library offers the following solution. The methods to Split and Merge are completely free in this library, even for commercial use.

using SautinSoft.Pdf;
using SautinSoft.Pdf.Facades;

// The each page will be saves as a separate PDF file: "Page 0.pdf", "Page 1.pdf" ...
// Can work with relative and absolute paths.
PdfSplitter.Split(@"Input.pdf", PdfLoadOptions.Default, 0, int.MaxValue, (pageInd) => $"Page {pageInd}.pdf");

Here is the more comprehensive sample: https://sautinsoft.com/products/pdf/help/net/developer-guide/split-pdf-files.php

Disclaimer: I am the co-author of SautinSoft.Pdf library.

Propeller answered 16/8 at 5:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.