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#.
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.
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.
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.
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.
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.
© 2022 - 2024 — McMap. All rights reserved.