在不知道扩展名为pdf文件的情况下转换任何文件类型的字节 [英] Convert Bytes of Any file Types without knowing extension to a pdf file

查看:90
本文介绍了在不知道扩展名为pdf文件的情况下转换任何文件类型的字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我经常在Google上冲浪数天,以获取以下查询的答案.如果能帮助我解决这个问题,我将不胜感激.

我们有不同类型的文件以字节数组形式存储在sql server的Image Datatype列中,但是我们没有该文件的扩展名.我必须打印所有满足条件的记录文件,这些记录文件将以字节数组形式保存为图像数据类型.我的问题是要实现此功能,为此,我正在寻找一种解决方案,例如是否可以通过任何方式进行后续操作.

1)如果我可以直接将字节数组发送到打印机.
2)如果我可以将所有记录的字节数组转换为pdf文件,然后将此生成的pdf发送至打印机.
3)我在google上找到的解决方案仅在我知道该字节的文件类型但无法获取这些字节的文件类型的情况下有效.
4)我通过了很多论坛和示例,但都没有用.

非常感谢您的阅读.

谢谢和问候,
Chintan Desai

Hi,

I surfed google very much for days to get an answer for a below query. I would highly appreciate if any can help me to come out of this problem.

We have Different types of files stored in an Image Datatype column in sql server as a byte array but we dnt have an extension of that file. I have to print all records files which are saved as a byte array in an image data type if they satisfied a condition. My problem is to achieve this functionality and for that I am looking for a solution like if there is any way by which can do following stuff.

1) If I can directly send bytes array to a printer.
2) If I can convert bytes array of all records to a pdf file and than send this generated pdf to a printer.
3) The solutions I found on google works only if I know file type of that bytes but there is no way to get a file type of those bytes.
4) I passed through lot of forums and examples but none of them are working.

I am very much thankful to you for reading out.

Thanks and Regards,
Chintan Desai

推荐答案

您不能.

没有保证从文件内容中识别文件类型的方法.某些文件可能是可能的-好的"数据格式通常包括描述创建该内容或应用程序的标头-但那里还有更多的讨厌"格式.

即使您可以识别内容,也无法将其转换为PDF,除非您拥有该特定文件格式的直接转换器,或者从特定格式转换为通用格式,然后可以转换为PDF. .

直接将字节发送到打印机可能会产生一堆满是垃圾的打印页面!
You can''t.

There is no guaranteed way to identify a file type from it''s content. It may be possible for some files - "nice" data formats generally include a header which describes the content or app which created it - but there are a lot more "nasty" formats out there.

Even if you can identify the content, there is no way to just convert it to a PDF, unless you have either a direct converter for that specific file format, or a convert from the specific format to a generic format you can then convert to PDF.

Sending bytes directly to a printer will probably generate a load of printed pages covered with total rubbish!


这是您要查找的内容吗?
http://www.c -sharpcorner.com/UploadFile/1a81c5/convert-file-to-byte-array-and-byte-array-to-files/ [
Is this what you are looking for?
http://www.c-sharpcorner.com/UploadFile/1a81c5/convert-file-to-byte-array-and-byte-array-to-files/[^]


这篇关于在不知道扩展名为pdf文件的情况下转换任何文件类型的字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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