如何从二进制arry数据中查看PDF文件 [英] How to view PDF file from binary arry data

查看:208
本文介绍了如何从二进制arry数据中查看PDF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

'文件不以'%PDF-'开头

C:\ Users \ AppData \ Local \ Temp \ tmp34A8.pdf



我在编写此代码时遇到上述错误.........



' File does not begin with '%PDF-'
C:\Users\AppData\Local\Temp\tmp34A8.pdf

I got above error while I wrote this code.........

img5 = (byte[])resultTable.Rows[0]["image5"];

                    if (img5.Length != 0)
                    {

                        axAcroPDF1.Refresh();
                        string spathfile = System.IO.Path.GetTempFileName();
                        System.IO.File.Move(spathfile, System.IO.Path.ChangeExtension(spathfile, ".pdf"));
                        spathfile = System.IO.Path.ChangeExtension(spathfile, ".pdf");                    
                        System.IO.File.WriteAllBytes(spathfile, img5);                    
                        axAcroPDF1.LoadFile(spathfile);

                    }

推荐答案

我检查的最后一个,Reader控件不支持从文件以外的任何文件加载或URL。



此外,您获得的错误意味着您写入临时文件的数据不是正确的PDF文件。它以某种方式被破坏。
The last I checked, Reader control doesn't support loading from anything but a file or URL.

Also, the error you got means that the data you wrote to the temp file is not a proper PDF file. It is corrupted somehow.


这是众所周知的问题......

您需要在iframe标签中加载pdf这样



this is very well known issue...
You need to load pdf in Iframe tag like this

<iframe src="@Url.Action("ViewPdf","Customer")"    width="80%" style="height:20em">

</iframe>


这篇关于如何从二进制arry数据中查看PDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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