C#写PDF文件-PDF File Writer

PDF File Writer

这是一个使用C#创建PDF文件的库。

这个库支持以下的PDF功能

  • Graphics: drawing lines, rectangles, polygons, Bezier curves, foreground and background color, patterns and shading. Section 2.1 Coordinate System.
  • Image: drawing raster (Bitmap) images and vector (Metafile) images. Section 2.4. Image Support.
  • Text: drawing text lines and text in columns. Section 2.3 Language Support.
  • Barcode: support for Barcode 128, Barcode 39, Barcode interleaved 2 of 5, Barcode EAN13 and Barcode UPC-A. Section 2.5 Barcode Support.
  • QR Code: support for two dimensions barcode. Section 2.8 QR Code Support.
  • Encryption: support for AES-128 encryption. Section 2.6 Encryption Support.
  • Web Link: Web link interactive support. Section 2.7 Web Link Support.
  • Bookmark: Support for document outline. Section 2.9 Bookmark Support.
  • Named Destinations: Support for making Acrobat open the PDF document at a specific page. Section 2.22 Named Destinations.
  • Charts: Support for Microsoft Charting. Section 2.10 Charting Support.
  • Print to PDF: Create a PDF document from PrintDocument process. Section 2.11 PrintDocument Support.
  • Display data tables. Section 2.12 Data Table Support
  • Play video files. Section 2.13 Play Video Files
  • Play sound files. Section 2.14 Play Sound Files
  • Attach data files. Section 2.15 Attach Data Files
  • Reorder pages. Section 2.16 Reorder Pages
  • PDF document output to a file or to a stream. Section 2.17 Document Destination.
  • PDF document information dictionary. The PDF reader displays this information in the Description tab of the document properties. The information includes: Title, Author, Subject, Keywords, Created date and time, Modified date and time, the Application that produced the file, the PDF Producer. Section 2.18 Document Information Dictionary.
  • Memory control: Write contents information of completed pages to output file and free unused memory with garbage collector. Section 2.19. Memory Control.
  • Draw artwork defined by System.Windows.Media.PathGeometry class. Input argument can be text string or PathGeometry class. Section 2.20 Windows Presentation Foundation WPF
  • Transparency or opaqueness is now available for painting shapes, lines, text and images. Your application can set the alpha component of color for all graphics and text. Section 2.21 Transparency, Opacity, Alpha Color Component and Blending
  • Blend. The new library supports the PDF color blending scheme. Blending defines how the color of a new item painted over a previous item is handled. Section 2.21 Transparency, Opacity, Alpha Color Component and Blending

只需要6步

Step 1: Create one document object PdfDocument.
Step 2: Create resource objects such as fonts or images (i.e.PdfFont or PdfImage).
Step 3: Create page object PdfPage.
Step 4: Create contents object PdfContents.
Step 5: Add text and graphics to the contents object (using PdfContents methods).
Repeat steps 3, 4 and 5 for additional pages
Step 6: Create your PDF document file by calling CreateFile method of PdfDocument.

Step 5 is where most of your programming effort will be spent. Adding contents is achieved by calling the methods of PdfContents class to render graphics and text. The contents class has a rich set (about 100) of methods for adding text and graphics to your document.

最低需要.net 4.0支持。

资源下载

版本更新

http://www.codeproject.com/script/Articles/ListVersions.aspx?aid=570682