I'm building a custom CRM and I'd like to know what would be the best way to print an invoice. To me, a simple solution would be to have an HTML template of an invoice form (with an HTML table in it) and then use some control to preview/print/export it. Is there a way to do this? Or is there a better way to accomplish this end?
Any help is greatly appreciated!
The topic of converting from HTML to our PDF documents engine is discussed in this thread:http://forums.infragistics.com/forums/t/17051.aspx
To summarize:
Matt Snyder"]There isn't a built-in way to render more than very basic HTML however; that functionality is provided off the IText.AddRichContent method.
I will create the HTML myself. I just need to know the name of the object to load it into and call Print() on it. Is there an object I can load HTML in and it will convert it to PDF?
Thanks!
Exporting to PDF would be done by creating a Report object from our Documents engine (Infragistics.Documents.Report.Report). I suggest looking over the help documentation on the Infragistics Documents engine (link taken from our online help documentation for NetAdvantage for .NET 2008 Volume 3) for more details.
We don't have any controls or components that can assist you in creating HTML output as you've described. I expect that this will take more work to achieve than using our Documents engine.
Thank you for your response. I would like to stick with the HTML then because it is relatively easy to create a template and load data into it.
What object would I use for that and how would I tell it to print the HTML or export it to PDF? Do you have a sample code?
You have a number of options available to you.
The best option I can think of is to use the Infragistics Documents engine to create a PDF or XPS document. This provides a relatively easy and flexible way to put your data into a printable format.
Putting your data into HTML, as you've described, is another option. It's a portable format, similar to PDF.
Another option is to use the basic .NET printing functionality, which means you use a System.Drawing.Graphics object to "draw" what you want on the printing "surface." This gives you the most flexibility, and is potentially the best performing of these three approaches - however, this requires some expertise with the System.Drawing namespace to get a useful result.