从Web应用程序打印文本文件 [英] printing text file from web application

查看:84
本文介绍了从Web应用程序打印文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我已经创建了一个小型Web应用程序,之后我将从Web应用程序中将一些文本写入文本文件(记事本文件)中.
我将从我的Web应用程序本身打印该文本文件,然后将其打印到默认打印机.
它在我的本地PC上运行良好,但是当我通过IIS将此Web应用程序配置为客户端PC时,效果不佳,
只有我可以将我的文本写入文本文件(记事本文件),但是该文本文件无法打印..

这是该代码

hi all

i have created small web application, from my web application i ll write some text into in text file(notepad file)after that
i ll print that text file from my web application itself,then it will be print to default printer..
its works well in my local pc, but when i configure this web application into client pc through IIS its not working well,
only i can write my text into text file(notepad file), but that text file is not printing..

this is the code for that

private void ReadFile()
        {
            string path;
            path = Server.MapPath("~/Temp_Image/");
            string docName = "Truevalue.txt";
           // string docPath = @"C:\sample\";
            string docPath = path;
            printDocument1.DocumentName = docName;
            using (FileStream stream = new FileStream(docPath + docName, FileMode.Open))
            using (StreamReader reader = new StreamReader(stream))
            {
                stringToPrint = reader.ReadToEnd();
            }
	     printDocument1.Print();
        }

推荐答案

您将无权访问要在其上进行打印的打印机.
You will not have access to the printer you are trying to print on.


这没有任何意义. ,正如Abhinav向您解释的那样.首先,没有记事本文件"之类的东西.但是这里没有问题:用户可以打印您提供的任何内容就可以了.无论如何,如果某些Web应用程序试图在其打印机上进行打印,那么用户将不会喜欢这种烦人的帮助". Web浏览器的打印..."菜单项有什么用?

—SA
It makes no sense, as Abhinav explained to you. To start, there is no such thing as "notepad file". But there is no a problem here: a user can print any content you provide just fine. Anyway, users would not appreciate such annoying "help" if some Web application is trying to print on their printer. What''s the Web browser''s "Print…" menu items for?

—SA


这篇关于从Web应用程序打印文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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