如何使用c#转换二进制PDF文件并在浏览器中显示为PDF? [英] How can I convert the binary PDF file and display as PDF in the browser using c#?
本文介绍了如何使用c#转换二进制PDF文件并在浏览器中显示为PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有许多二进制格式的PDF文档,这些文档在SQL Server 2008数据库中.
我的ASP.Net页面中有一个gridview.
当用户单击记录的任何ID列时,我需要在浏览器中打开pdf.
有免费的在线PDF查看器控件吗?
如何使用c#转换二进制PDF文件并在浏览器中显示为PDF?
问候,
Venki Desai.
Hi to all,
I have many PDF documents in binary format, which is in the SQL Server 2008 database.
I have a gridview in my ASP.Net page.
When a user clicks on any ID column of the record I need to open the pdf in the browser.
Are there any free online PDF viewer controls out there?
How can I convert the binary PDF file and display as PDF in the browser using c#?
Regards,
Venki Desai.
推荐答案
您不需要将其转换为PDF,它已经是.您只需要发送二进制流.
You don''t need to convert it to a PDF, it already is. You just need to send the binary stream.
private void SendDocument(byte[] buf)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ContentType = "Application/pdf";
HttpContext.Current.Response.AppendHeader("Content-Length", buf.Length.ToString());
HttpContext.Current.Response.BinaryWrite(buf);
HttpContext.Current.Response.End();
}
这篇关于如何使用c#转换二进制PDF文件并在浏览器中显示为PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文