开发者

Generating and printing an invoice

开发者 https://www.devze.com 2023-02-12 15:27 出处:网络
I would like to generate an invoice and print it in the background (without being showed to the user of the application),once the cashier has received the cash from the customer.

I would like to generate an invoice and print it in the background (without being showed to the user of the application),once the cashier has received the cash from the customer.

I don't know how to do that in WPF,i tried to create a user control and pass the needed objects and bind it to a DataGrid control into this user control and print it.

Someone suggested to u开发者_开发知识库se Crystal Report and pass a parameter then generate the invoice and print it,but i don't know how to do that technically.

Thanks in advance


In WPF you have many possibilities:

  • Printing via XPS, look here for more information. It's really flexible and powerfull but also a little complex. Here you will find a short example.
  • Create a FlowDocument and print out this. This way is more simple, has a lot of features and also gives you good print quality. However it has a specific goal: Support of flowing documents. Therefore it's not always the best choice because of formatting limitations.
  • A very simple possibility to use PrintDialog.PrintVisual. With this you can print out quickly the contents of a visual. This is good for a simple solution but very limitted.
  • Use a reporting tool such as Microsoft Report Viewer. You can use it also from WPF and it is very powerfull and free. Take care, there are many different versions out there. I would use the newest one (V3). This is the version VS2010 has an integrated designer.

All these ways can be used to print out without direct user-interaction.

You have written: I don't know how to do that in WPF,i tried to create a user control and pass the needed objects and bind it to a DataGrid control into this user control and print it.. To see how the result becomes, take the PrintDialog.PrintVisual-method, it seems you also have all you need and then you will see if it fits your needs. Otherwise choose one of the other technologies.

For creating nice formatted print-documents, I would propose to use a reporting technology, because of the flexibility they provide. You can do it also in XPS but in general, this is much more work (the more complex the layout becomes) and is also less supportable. However, it's also an effort to learn and embedd the reporting technology into your app.

0

精彩评论

暂无评论...
验证码 换一张
取 消