如何将 PDF 文件拆分为页面(最好是 C#)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/122109/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I split up a PDF file into pages (preferably C#)
提问by Peter
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#.
我的客户有一个多页 PDF 文件。他们需要按页拆分。有谁知道这样做的方法 - 最好是在 C# 中。
采纳答案by ConroyP
PDFSharpis an open source library which may be what you're after:
PDFSharp是一个开源库,它可能是您所追求的:
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
主要特点
- 从任何 .Net 语言即时创建 PDF 文档
- 易于理解的对象模型来组成文档
- 一个用于在 PDF 页面以及窗口或打印机上绘图的源代码
- 修改、合并和拆分现有 PDF 文件
This sampleshows how to convert a PDF document with n pages into n documents with one page each.
此示例演示如何将具有 n 页的 PDF 文档转换为每页一页的 n 个文档。
回答by Guy Starbuck
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.
我使用ITextSharp做到了这一点——有一些商业选项可能有一个很好的 API,但这是开源和免费的,并且不难使用。
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.
查看这段代码,这是他们的代码示例之一——非常好。它按照传入的页码将 PDF 文件拆分为两个文件。您可以将其修改为逐页循环和拆分。
回答by operknockity
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.
还没有玩过,但你可以看看Aspose.Pdf.Kit for .NET 和 Java。它是商业性的,因此您需要支付许可费用,但如果您需要商业支持,它可能对您有用。
回答by Metro Smurf
Siberix offers a reasonably costed commercial library for creating PDF's on the fly in .NET: http://siberix.comYou can create the PDF's programmatically or through an XML transformation (and a combination of both IIRC).
Siberix 提供了一个成本合理的商业库,用于在 .NET 中即时创建 PDF:http://siberix.com 您可以通过编程方式或通过 XML 转换(以及 IIRC 的组合)创建 PDF。
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.
我在几个项目中使用了他们的库,发现他们的库不仅易于使用,而且他们的电子邮件支持令人难以置信。而且许可证也很便宜。