13
2010
PDFsharp – A .NET library for processing PDF
- Overview:
PDFsharp is a .NET library for processing PDF file. You create PDF pages using drawing routines known from GDI+. Almost anything that can be done with GDI+ will also work with PDFsharp. Only basic text layout is supported by PDFsharp, and page breaks are not created automatically. The same drawing routines can be used for screen, PDF, or meta files.
- 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
- Images with transparency (color mask, monochrome mask, alpha mask)
- Newly designed from scratch and written entirely in C#
- The graphical classes go well with .NET
Improvements of Version 1.30
- Private Font Collections for WPF version: load TrueType fonts (e. g. from embedded resources) and use them in PDF documents
- Several bug fixes for WPF version
- Help file for Visual Studio 2008 (and 2005): context help for PDFsharp and MigraDoc classes available if you hit F1
- Standalone Help file for Windows: .CHM file that can be viewed without Visual Studio
Improvements of Version 1.20
- Can use either GDI+ or WPF
- Includes preview of XPS to PDF converter
- Includes binaries (DLL files, nowadays called Assemblies)
- Please note: Developed for and tested with .NET 2.0 and Visual Studio 2005 and with .NET 2.0/3.0 and Visual Studio 2008.
Improvements of Version 1.00
- Improved support for Unicode
- Font embedding and subsetting
- Bug fixed in connection with Acrobat 8
- New sample demonstrates using PDFsharp and MigraDoc to create a document
- Please note: The support for .NET 1.1 and Visual Studio 2003 was dropped. Developed for and tested with .NET 2.0 and Visual Studio 2005.
Improvements of beta 4
- Support for Unicode
- Advanced text layout with new TextFormatter class
- Three new C# samples
- Various bug fixes
- Many minor improvements
Improvements of beta 3
- Two new samples: ConcatenateDocuments and XForms
- Bug fixes
- Many improvements
Improvements of beta 2
- Linear gradient brushes
- XGraphics.Save/Restore now work properly with nested calls
- TextAnnotations, Rubber stamp annotations
- Read content of interactive form fields (AcroForms) (still under construction)
- Write interactive form fields (AcroForms) (still under construction)
- First two bar code types (Code2of5Interleaved and Code3of9Standard)
- XPdfForm objects as templates. Use XGraphics class to create PDF form objects.
Graphics
The graphical objects follow the design pattern of the .NET framework. With one set of functions you can draw on a PDF page as well as on a System.Drawing.Graphics object. Your application can render its output in a window, on the printer or in a PDF document.
- Lines, polylines, arcs, Bézier splines, canonical splines
- Rectangles, rounded rectangles, ellipses, polygons, pies, closed splines, paths
- RGB, CMYK, and gray scale colors with transparency
- Pens and brushes for drawing and filling
- GDI+ like predefined colors, pens and brushes
- Matrix transformations
- BMP, PNG, GIF, TIFF, and JPEG images
- Image masks and transparency
- Form XObjects
- Clipping through graphical path
- Linear gradient brushes
- First two bar code types (Code2of5Interleaved and Code3of9Standard)
Text
- TrueType fonts / OpenType fonts with TrueType outline
- Matrix transformations
- Converting glyphs to a graphical path
- WinAnsi and Unicode encoding
- TextAnnotations, Rubber stamp annotations
- Unicode support in PDF files
- TextFormatter class for simple text layout
Security
- Encryption with 40/128 bit with password
- Document access permissions
PDF Features
- Supports PDF versions 1.2 through 1.4 (including the transparency features introduced with Adobe Reader 5.0); these files can be read and written
- Can create PDF files marked for PDF version 1.2 (Adobe Acrobat Reader 3) through 1.7 (Adobe Reader 8); newer Reader versions can always read the files
- Read content of interactive form fields (AcroForms) (still under construction)
- XPdfForm objects as templates. Use XGraphics class to create PDF form objects.
- Samples:
Hello World:
using System;
using System.Diagnostics;
using System.IO;
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
namespace HelloWorld
{
///
/// This sample is the obligatory Hello World program.
///
class Program
{
static void Main(string[] args)
{
// Create a new PDF document
PdfDocument document = new PdfDocument();
document.Info.Title = "Created with PDFsharp";
// Create an empty page
PdfPage page = document.AddPage();
// Get an XGraphics object for drawing
XGraphics gfx = XGraphics.FromPdfPage(page);
// Create a font
XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic);
// Draw the text
gfx.DrawString("Hello, World!", font, XBrushes.Black,
new XRect(0, 0, page.Width, page.Height),
XStringFormats.Center);
// Save the document...
const string filename = "HelloWorld.pdf";
document.Save(filename);
// ...and start a viewer.
Process.Start(filename);
}
}
}
See the PDF file created by this sample: HelloWorld.pdf (3 kB)
You can view all samples here.
- Download:
- Download from SourceForce: Bin and Project
- Download from CodePlex: Bin and Project
Enjoy it
Leave a comment
Categories
- ASP.NET (2)
- Make Money Online (2)
- Plugins (1)
- Programming (2)
- Themes (2)
- Tip/Trick (1)
- Uncategorized (1)
- We Online (1)
- Web Server (1)
- WordPress (2)
Free hosting and domain
Tags
8080 Advertise Apache ASP.NET Authentication BlackBerry Branchr C# CLSID CodePlex COM CSharp Feed FeedBurner free domain free hosting GMail http IIS IIS6 IIS7 infolinks InprocServer32 Joomla netsh PDFsharp PHP phpMyAdmin ping port related tags RSS Site5 SourceForce Virtual host WordPress WordPress for BlackBerry WordPress plugins WordPress security WordPress templates WordPress themes WP WPWebHost XAMPP
WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.
An article by Mr.AD










