如何打印一个文本文件或文本框的内容,在地铁的应用程序? [英] How do I print a TextFile OR contents of a TextBox in Metro apps?

查看:133
本文介绍了如何打印一个文本文件或文本框的内容,在地铁的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在地铁应用程序中的文本框控件,需要能够简单地打印内容。我已经做了我的研究,自从Windows 8的开发preVIEW是四周,我仍然无法搞清楚。

I have a TextBox control in my Metro app and need to be able to simply print its contents. I have done my research ever since Windows 8 Dev Preview was around and I still cannot figure it out.

我已经试过样品,阅读其他的答案和阅读文档 - 过来,过来,过来。它只是似乎并不可能。所以,以后有什么,2年?我提供所有我的名声(好,尽可能多地将允许)的希望,有人能帮助我。

I've tried samples, read other answers and read the documentation - over, and over, and over. It just doesn't seem possible. So, after what, 2 years? I'm offering all my reputation (well, as much as they'll allow) in the hopes that someone can help me.

推荐答案

在这里,我创建了一个简单的辅助类,帮助您打印文本框内容及其格式。你只需要调用类打印机的静态方法。在GitHub该项目还包含测试应用程序。

Here I have created a simple helper class which help you to print the Textbox content with its formatting. You just need to call static method of class Printer. The project on GitHub also contain test app.

await Printer.ShowPrintUIAsync(PrintPreview, MyTextBox, Guid.NewGuid().ToString());

打印preVIEW 是一个画布,这是强制性显示打印preVIEW器件的魅力。您的XAML申报。

PrintPreview is a canvas, which is mandatory to show print preview in device charm. You have to declare in your XAML.

MyTextBox 是一个文本框对象,其文本内容将被打印出来。

MyTextBox is a text box object, whose text content is going to be printed.

Guid.NewGuid()的ToString()是用于打印文件的文件名。 (它将如果你是通过印刷创建PDF或XPS文件被应用。)

Guid.NewGuid().ToString() is a file name for printing the document. (It will be applied if you are creating PDF or XPS file via printing.)

您可以通过的NuGet 添加辅助类。如果你想提高我的现有的辅助类,叉子 GitHub上

You can add helper class via NuGet. If you want to enhance my existing helper class, fork on GitHub

这篇关于如何打印一个文本文件或文本框的内容,在地铁的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆