0

I have an Windows Store app I I want to print one of the pages. I looked for it in the web and I must select printers from devices in charm but there aren't anything listed. when I looked into devices in settings I see printer is added (via network but when I connect my Phone nothing happens either) in devices I see a message saying "Nothing can be sent from app" How can I add printer to charm or is there any command I can write in c# to print?

Youngjae
  • 24,352
  • 18
  • 113
  • 198
eomer
  • 3,514
  • 7
  • 30
  • 42
  • maybe this link could help : http://social.msdn.microsoft.com/Forums/windowsapps/en-US/3e23d1ca-9a4d-4677-b2d9-ea5b48f7c9a2/how-to-enumerate-a-network-printer-in-metro-apps?forum=tailoringappsfordevices –  Feb 17 '14 at 13:09
  • thanks BenH but I have no interest in enumarating the printers. either I show the printers on devices in charm or write codes for printing – eomer Feb 17 '14 at 13:17

2 Answers2

0

See http://msdn.microsoft.com/en-us/library/windows/apps/hh465196.aspx :

Your app accesses Windows printing by registering for the Print contract in each view of the app from which you want users to be able to print. Registering for the Print contract means obtaining a PrintManager object, creating a PrintTask object, and handling the PrintDocument events.

Andy Rich
  • 1,942
  • 10
  • 14
  • That's what I've been doing.It throws exception when it tries to load the image for the preview. "Value does not fall within the expected range", null object every once in a while in random places. This is the sample I have been trying to implement, it's huge. – Redhead Dec 07 '15 at 19:14
0

If you can't find the printer listed in the UI you should maybe update your drivers.

So if you want to print a Page or any other FrameworkElement there is a library for this the Windows.Graphics.Printing.PrintManager.

I would recommend this example. If you just follow the example you will achieve to print any Page.

Please take care if you want to resize your acutal shown Page. In that case you should initialize a copy of this page that you want to print and resize this or render it with RenderTargetBitmap. This can help you too if the Pageisnt shown correctly in the Preview or is printed with possible missing parts.

Peter
  • 1,655
  • 22
  • 44