如何将字节数组转换为pdf [英] How to convert a byte array to a pdf

查看:1233
本文介绍了如何将字节数组转换为pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我在数据库中存储了一个字节数组(包含pdf文件),我想将其打开为pdf文件并将其嵌入iframe或任何其他面板中并显示它,而无需将其保存在localdisk上.

Hello,

I have a byte array(of a pdf file)stored in my database and I want to open it as a pdf file and embed it in iframe or any other panel and display it, without saving it on localdisk. How can I do it?

推荐答案

在Acrobat论坛上有一些与此有关的内容.这个例子是用C ++编写的,但并不是那么容易.但也许它可以带您到某个地方.

http://forums.adobe.com/message/2018299#2018299 [ http://pastebin.com/f3cb079f8 [ ^ ]

祝你好运!
There is something on the Acrobat forum about this. The example is in C++ however and it isn''t all that easy. But maybe it can get you somewhere.

http://forums.adobe.com/message/2018299#2018299[^]

http://pastebin.com/f3cb079f8[^]

Good luck!


最大的问题是,这个字节数组到底是什么?它是图像文件吗?是文字吗?无论哪种方式,您都需要某种PDF库来执行此操作,但是您的问题比大多数PDF问题都更难回答,因为答案在一定程度上取决于您使用的数据类型(仍然会找到"图书馆并购买它,例如).
The big question is, what on earth is this byte array in the first place ? Is it an image file ? Is it text ? Either way you need some sort of PDF library to do this, but your question is harder to answer than most PDF questions, because the answer depends on what data you''re working with, to a degree ( it will still be ''find a library and buy it, tho )


要执行此操作,您需要 ITextSharp .

只需下载并用于创建PDF文档:

To do this you need ITextSharp.

Just download it and use to create PDF document:

Document myDocument = new Document(PageSize.LETTER);
PdfWriter.GetInstance(myDocument, new FileStream("mydocument.pdf", FileMode.Create));
myDocument.Open();
myDocument.Add(new Paragraph(Encoding.UTF8.GetString(bytes)));
myDocument.Close()



:)



:)


这篇关于如何将字节数组转换为pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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