如何在C#中用数据库在阅读器中显示pdf [英] How to display pdf in reader from database in C#

查看:73
本文介绍了如何在C#中用数据库在阅读器中显示pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我在Windows应用程序中工作我已成功保存pdf在数据库中现在我想在adobe reader中显示我已经从工具箱中添加

我该怎么办呢?为什么我能够在adobe reader中查看pdf



我尝试过:



  byte  [] DisplayImage =( byte  []) (dt.Rows [ 0 ] [ 1 ]); 
MemoryStream mem = new MemoryStream(DisplayImage);

axAcroPDF1.LoadFile(DisplayImage);





i有使用此代码但在这里我无法将dt行转换为adobe reader

解决方案

您可以在系统上加载默认的Web浏览器(大多数现代浏览器可以显示PDF文件),并将pdf文件的路径作为您的URL。 / blockquote>

使用本机.NET解决方案可能会有更好的运气,而不是依赖于用户计算机上可能不存在的ActiveX控件。



PdfiumViewer [ ^ ]是一个基于GooglePDFium项目的开源.NET库。您可以通过 NuGet 安装它[ ^ ],它似乎是积极维护的。



如果你想坚持在ActiveX控件中,您需要检查 LoadFile 方法所期望的参数。我见过的所有内容都表明它想要一个磁盘上PDF文件的路径,而不是字节数组或流。


hello i am working in windows application in this i have successfully save pdf in database now i want to display that in adobe reader which i have been added from toolbox
what should i need to do thats why i can able to view pdf in adobe reader

What I have tried:

byte[] DisplayImage = (byte[])(dt.Rows[0][1]);
           MemoryStream mem = new MemoryStream(DisplayImage);

           axAcroPDF1.LoadFile(DisplayImage);



i have use this code but here i cannot convert dt rows to adobe reader

解决方案

You could load the default web browser (most modern browsers can display PDF files) on the system with the path to the pdf file as your URL.


Rather than relying on an ActiveX control, which may not be present on your users' computers, you might have better luck using a native .NET solution.

PdfiumViewer[^] is an open-source .NET library based on Google's "PDFium" project. You can install it via NuGet[^], and it seems to be actively maintained.

If you want to stick with the ActiveX control, you'll need to check what the LoadFile method expects as its parameter. Everything I've seen suggests it wants a path to a PDF file on disk, not an array of bytes or a stream.


这篇关于如何在C#中用数据库在阅读器中显示pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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