views:

854

answers:

3

I'm in need of a solution to print or export (pdf/doc) from C#. I want to be able to design a template with place holders, bind an object (or xml) to this template, and get out a finished document.

I'm not really sure if this is a reporting solution or not.

I also don't want to have to roll my own printing / graphics code -- I'd like all display concerns handled in a template.

I initially think of this as something Crystal Reports can do (although I've never used CR), but I'm not sure if I'm abusing the system here -- I'm not really interested in binding ADO.NET datasets at the moment (screw datasets). Can Crystal deal with binding to objects?

Does SSRS or WPF play in this field too?

+1  A: 

Might read through this thread: http://groups.google.com/group/nhusers/browse_thread/thread/e2c2b8f834ae7ea8

Seems a lot of people like iTextSharp http://itextsharp.sourceforge.net/

Will Shaver
A: 

For Word docs, look into Word's Mail Merge feature and Word automation. I did this recently in a form letter printing project. Basically what I did was create a Word template file (file extension .dot) and in this template file I defined MergeFields in a standard form letter. My application queries a database for the records it needs to print and then for each record it returns it matches fields in the database with these merge fields and sends the result (the merged doc) to the printer.

It's working really well and if I had a link that gave a definitive explanation, I'd provide it (check back here, I'll see if I can't find the most useful ones). Hopefully I've provided enough keywords to let you find your own resources. I can go into more detail if you need.

I've never had to export PDF files but for a project I'm working on now I'll have to. For a free solution my research has lead to iTextSharp (like Will Shaver points out) but I've only done the initial investigations and I have found a few pay solutions I might end up resorting to.

Jay Riggs
+1  A: 

A subset of WPF-P is XPS which can be used to present your objects via databinding. One of the best choices if you are already using WPF.

Google Keywords: XPS, FixedDocument, FlowDocument, WPF Printing

Sven Hecht