如何打开文件以从内存流查看 [英] How To Open A File For Viewing From A Memorystream

查看:83
本文介绍了如何打开文件以从内存流查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在与iTextSharp一起使用值填充pdf字段.我可以正常使用,但一切都基于从网络上的访问.我正在尝试通过控制台应用程序执行此操作,而不涉及Web响应.下面的代码将打开HttpContext中生成的pdf文件.我的问题是有一种等效的方法可以打开pdf以便在不使用HttpContext的情况下在本地查看吗?

I''m now working with iTextSharp to fill in pdf fields with values. I got it working but everything is based on access from the web. I''m trying to do it via a console app not web responses involved. Below is the code that will open the resulting pdf file from a HttpContext. My question is there an equivalent way to open a pdf for viewing locally without using HttpContext?

var response = HttpContext.Current.Response;

if (!string.IsNullOrEmpty(attachmentFilename))
    response.AddHeader("Content-Disposition", "attachment; filename=" + attachmentFilename);

response.ContentType = "application/pdf";
response.BinaryWrite(contents);
response.End();

推荐答案



如果您编写此dat pdf文件,则它将在用户系统pdf阅读器中打开.用户将获得一个msg窗口,其中包含"open","save"等选项.如果用户单击打开,则该文件将在pdf阅读器中打开.

有很多Web控件可以在本地查看pdf,而不会像以前一样显示msg窗口.在这种情况下,您只需设置该Web控件的filepath属性即可,而无需在响应对象中将文件传递给用户.


如果我们单击带有编辑器的google docs中显示的视图链接,就只能像google docs一样在网页中显示pdf.

我说的对吗.
Hi

If you write this dat pdf file will open in user system pdf reader.User get a msg window with options like "open" ,"save".If user clicks open that file is open in pdf reader.

There are somany webcontrols for viewing pdf in webpage locally without showing msg window like as in previous situation.In this case you can just set filepath property of that webcontrol no need to pass your file to user in response object.


You''ve to show pdf in your webpage only like google docs if we click on view link it shows in google docs with editor.

Am I right .


这篇关于如何打开文件以从内存流查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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