iTextSharp is a library that allows you to generate PDF files on the fly.
Report.NET is a powerful library that will help you to generate PDF documents in a simple and flexible manner. The document can be created with data that have been retrieved from any ADO.NET data set.
PDFsharp is a C# library that easily creates PDF documents on the fly. The same GDI+ like drawing routines can be used to create PDF documents, draw on the screen, or send output to any printer. PDFsharp can also modify, merge, and split existing PDF files or incorporate pages from existing PDF files into new PDF documents.
SharpPDF is a C# library that implements different objects for the creation of PDF documents with few steps. It is created for .NET framework 1.1 and it can create 100% compatible PDF
PDFjet Open Source Edition is a library for dynamic generation of PDF documents from Java and .NET. The PDFjet Open Source Edition has the following features:
* Drawing support for: points, lines, boxes, circles, bezier curves, polygons, stars, complex paths and shapes.
* Text: unicode support, text kerning when using the Helvetica and Times-Roman families of core fonts, embedding hyperlinks.
FO PDF is similar to ASP.NET Server Controls, written in C#
PDF Clown is a C# 2.0 library for reading, manipulating and writing PDF files, with multiple abstraction layers to satisfy different programming styles: from the lower level (PDF object model) to the higher (PDF document structure and content streaming). Its primary target platform is GNU/Linux, but thanks to the Mono project it’s virtually platform-agnostic.
http://alex.buayacorp.com/merge-pdf-files-with-itext-and-net.html
http://www.wacdesigns.com/2008/10/03/merge-pdf-files-using-c/
http://www.zachhunter.net/blog/2009/04/28/MergeAndCombinePDFsInC.aspx
http://stackoverflow.com/questions/177/how-do-i-programmatically-create-a-pdf-in-my-net-application
http://www.aneef.net/2008/07/24/create-pdf-files-on-the-fly-with-c-and-pdfsharp/
下面為使用iTextSharp來合併PDF檔的function
01 |
using iTextSharp.text; |
02 |
using iTextSharp.text.pdf; |
05 |
using System.Collections; |
06 |
using System.ComponentModel; |
09 |
/// <summary> 合併PDF檔(集合) </summary> |
10 |
/// <param name="fileList">欲合併PDF檔之集合(一筆以上)</param> |
11 |
/// <param name="outMergeFile">合併後的檔名</param> |
12 |
private void mergePDFFiles( string [] fileList, string outMergeFile) |
14 |
outMergeFile = Server.MapPath(outMergeFile); |
16 |
Document document = new Document(); |
17 |
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(outMergeFile,FileMode.Create)); |
19 |
PdfContentByte cb = writer.DirectContent; |
20 |
PdfImportedPage newPage; |
21 |
for ( int i = 0;i < fileList.Length;i++) |
23 |
reader = new PdfReader(Server.MapPath(fileList[i])); |
24 |
int iPageNum = reader.NumberOfPages; |
25 |
for ( int j=1;j<=iPageNum;j++) |
28 |
newPage = writer.GetImportedPage(reader,j); |
29 |
cb.AddTemplate(newPage,0,0); |
如要叫用可以用以下方式
1 |
private void mergePDF() |
3 |
string [] pdflist = new string [3]; |
4 |
pdflist[0] = "RPT01.pdf" ; |
5 |
pdflist[1] = "RPT02.pdf" ; |
6 |
pdflist[2] = "RPT03.pdf" ; |
7 |
mergePDFFiles(pdflist, "newpdf1.pdf" ); |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· C++代码改造为UTF-8编码问题的总结
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库