如何在iTextSharp中从byte []创建文档 [英] How can I create document from byte[] in iTextSharp

查看:96
本文介绍了如何在iTextSharp中从byte []创建文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找从byte[]加载代表PDF的iTextSharp文档的方法.

解决方案

如果b是表示有效PDF文件的byte[],则可以将PDF加载到iTextSharp中,如下所示:

PdfReader reader = new PdfReader(b);

现在您可以使用reader对象执行各种操作,例如使用PdfCopy类复制页面,使用PdfStamper在PDF上标记内容,等等.

阅读我的书的第6章以了解您可以(或不能)进行的操作使用PdfReader对象.如果要从PDF中提取文本,则需要整本书.如果您假设PDF是与Word相似的格式,则应该放弃希望.

总而言之,您的问题非常广泛.目前尚不清楚您在问什么. 加载到iTextSharp文档中"是什么意思?如果您指的是Document对象,那么您的问题可能是错误的,因为在处理现有PDF时通常不会使用Document对象,但是您会在我的书的免费章节中阅读所有内容. /p>

I'm looking for way to load an iTextSharp document from byte[] representing a PDF.

解决方案

If b is a byte[] that represents a valid PDF file, then you can load the PDF into iTextSharp like this:

PdfReader reader = new PdfReader(b);

Now you can do all sorts of things with the reader object, such as copy pages using the PdfCopy class, stamp content on the PDF using PdfStamper, and so on.

Read Chapter 6 of my book to find out what you can (or can't) do with the PdfReader object. You'll need the full book if you want to extract text from the PDF. You should abandon hope if you assume that PDF is a format that is similar to Word.

All in all, your question is very broad. It isn't clear what you are asking. What do you mean by "load into an iTextSharp document"? If you are referring to the Document object, your question may be wrong as you typically won't use the Document object when manipulating existing PDFs, but you'll read all about that in the free chapter of my book.

这篇关于如何在iTextSharp中从byte []创建文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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