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" ); |