查看字节[]在WPF应用程序全文字节、应用程序、全文、WPF

2023-09-03 22:34:11 作者:共一场星辰

您好我得到的一些字节PDF文件[] 我正在寻找一种方式来查看他们的WPF应用程序中。

Hi I got some pdf files in Byte[] and I'm looking for a way to view them inside a WPF application.

我已经看了 http://hugeonion.com/2009/04/06/displaying-a-pdf-file-within-a-wpf-application/ 但遇到了麻烦与Visual Studio不能够REF正确的DLL的,就像在注释。

I have already looked at http://hugeonion.com/2009/04/06/displaying-a-pdf-file-within-a-wpf-application/ But ran into problems with visual studio not being able to ref the correct dll's, just like in the comments.

但无论如何,这种方法只允许的LoadFile(字符串文件名),我会很喜欢的方式来直接使用,而不是浪费时间它保存到一个临时位置的字节[]。

But anyway, that method only allows LoadFile(string filename) and I would really like a way to use the Byte[] directly instead of wasting time saving it to a temp location.

据杰里尼克松回答

我添加了一个web浏览器进行测试,但它只是显示了打开文件对话框,在浏览器中显示的文件,而不是。

I added a WebBrowser to test it, but it just shows the Open file dialog instead of displaying the file in the browser.

 <Grid>
       <WebBrowser Name="myBrowser" Source="file://C:\mypdffile.pdf" />
  </Grid>

修改2

跑Win 7的64,改变我的应用程序的平台目标从值为anycpu至86使它工作。

Edit 2

Was running Win 7 64 and changing my app's Platform Target from AnyCpu to x86 made it work.

推荐答案

绝对最好的,最简单的就是嵌入一个Web浏览器,写你的byte []到一个临时位置,您的浏览器指向该位置。 Adobe的读者会呈现PDF内的浏览器,因此你的应用程序中。我已经做到了。它工作正常。

The absolute best and easiest is to embed a web browser, write your byte[] to a temp location and point your browser to that location. The Adobe reader will render the PDF inside the browser and thus inside your application. I've done it. It works fine.

写字节[]到一个文件: How以二进制转换为字节,并写在C#文件

Write byte[] to a file: How to convert Binary to Byte and write as a file in c#

查找Temp文件夹: 在Windows中创建一个临时目录?

Find Temp folder: Creating a temporary directory in Windows?