HomeAdd Ons Review: Create PDF Documents Inside .NET Apps
Review: Create PDF Documents Inside .NET Apps ByJim Mischel 2004-06-02
Article Rating: / 0
Rate This Article:
Add This Article To:
Component One PDF for .NET allows you to create PDF documents from your applications. It does just what it promises, too.
Creating PDF documents can be a tricky business. Doing it "manually" by trying to interpret the PDF specification is a lesson in frustration, and trying to use one of the free PDF libraries is only slightly less maddening. The folks at Component One have greatly simplified the process by creating an API that's very similar to the .NET Graphics API. If you understand how to draw shapes and text on a Windows Form, then you'll feel right at home with Component One PDF for .NET (C1PDF).
C1PDF, a part of Component One Studio but also available separately, is simple enough to get going. The installation program creates a directory under Program Files called Component One Studio .NET, and installs the C1PDF files in that hierarchy. Its four binaries are the Component One common routines DLL, the PDF library, and two charting libraries: one for 2D charts and one for 3D charts. The installed image occupies about 7 megabytes, which is also about the same size as the downloaded install image.
ADVERTISEMENT
C1PDF consists of five .NET classes that mimic the primary objects defined in the PDF specification: document, document info, page, page collection, and security. The primary class with which you will interact is C1PdfDocument. The API is well designed, small, and easy to use. I was able to use it in my own program after only a few minutes playing with the sample programs and browsing the help files.
Although small, the API appears quite complete. I was able easily to add advanced features like passwords, compression, and complex graphics in my documents. There's even a Write method that allows you to write raw PDF commands into the document stream. You'd need a detailed understanding of the PDF specification to make use of this method,
but it's nice to see that it's available if I need it. All in all, I was quite pleased with the power of the API.
Sample Programs
The package includes four sample programs written in C#. The big one, CreatePdf, shows how to use the most common PDF creation features: simple text, tables, alignment, images, multiple page sizes and orientations, and many others. The code is clean and easy to follow, with plenty of comments to explain what's going on. The other three projects, Charts, Metafile, and Security, show how to use more advanced features of the C1PDF library.
I was especially impressed with the Charts sample, which shows how to add charts created with the C1Chart and C1Chart3D packages to a PDF. Charts are rendered in the PDF as a series of graphics commands rather than as images. This results in graphics that can be resized without losing detail. If I were distributing PDF files containing charts, I'd certainly look into licensing those charting components.
The help files describe how to perform common tasks like creating and sizing documents, drawing text, images, and graphics, and creating pages and overlays. The help also includes good information about less-used features like bookmarks, attachments, links, and security. The help is not a reference to the PDF specification, but it does give you a lot of good information to get you started creating your own PDF documents. Help also includes a detailed reference to the various classes and enumerations contained in the package.
There are two versions of the help file: a standalone HTML Help version, and an integrated version that you can access from within Visual Studio. The first time you start Visual Studio after installing C1PDF, Visual Studio will take some time to add the C1PDF help files into its integrated help. This process took a little over a minute on my 700 MHz Pentium, but the result is well worth the wait. The full documentation for C1PDF is now available in the help window inside Visual Studio.
The license includes a single-seat developer license, and royalty-free rights to redistribute the PDF creation library with client applications. Additional developer seats and distribution on Web servers requires a separate license for each developer machine or Web server; site licenses are available. (The installed charting components are unlicensed versions that are not redistributable. Only the PDF creation library is redistributable with your license of C1PDF.)
From my brief period working with C1PDF in a small project, I was very impressed with its power and simplicity. The API is full featured and easy to use, the documentation is first rate, and the sample programs gave me working code that I could copy to get my program up and running in a very short time. If you need PDF support in your .NET application, you definitely should download the evaluation version of Component One PDF and take it for a test drive.