如何在不使用iText关闭PDF文件的情况下读取和写入PDF文件
我正在使用iTextSharp处理PDF文档 目前我正在阅读PDF(使用PDFReader和PDFStamper),在其中写入内容并关闭它。现在处理的过程越来越多,阅读PDF文档在我的应用程序中成为一项繁重的操作 我只想阅读PDF一次,并在最后关闭它。问题是,我还需要在每个进程之后在磁盘上更新文档(不关闭流)。我们怎样才能从itextsharp获得这样的成就如何在不使用iText关闭PDF文件的情况下读取和写入PDF文件,pdf,io,itextsharp,Pdf,Io,Itextsharp,我正在使用iTextSharp处理PDF文档 目前我正在阅读PDF(使用PDFReader和PDFStamper),在其中写入内容并关闭它。现在处理的过程越来越多,阅读PDF文档在我的应用程序中成为一项繁重的操作 我只想阅读PDF一次,并在最后关闭它。问题是,我还需要在每个进程之后在磁盘上更新文档(不关闭流)。我们怎样才能从itextsharp获得这样的成就 // ReadDocument() // WriteForProcess1() // UpdateDocumentOnDisk () /
// ReadDocument()
// WriteForProcess1()
// UpdateDocumentOnDisk ()
// ViewUpdatedDoc()
// WriteForProcess2()
// UpdateDocumentOnDisk ()
// ViewUpdatedDoc()
// WriteForProcess3()
// UpdateDocumentOnDisk ()
// ViewUpdatedDoc()
// CloseDocument()
你想要什么是不可能的: 如果我理解正确,你想
PdfStamper
PdfStamper
并写入最终结果文件PdfReader
关于你的中心问题:
在我的应用程序中,阅读PDF文档已成为一项繁重的操作
根据您在每次迭代中操作PDF的方式,可能不需要解析整个现有PDF,例如,如果您每次仅操作一小部分PDF页面或仅附加新页面
如果是这种情况,您应该考虑使用<代码> PdfReader < /C> >构造器,该构造器只部分解析PDF并复制其余部分,而不需要解析资源。 PS:OP评论:
RandomAccessFileOrray中有什么?这是用来阅读部分文件的东西吗。它将文件读取时间从3秒大幅减少到300毫秒:) 是的,
PdfReader
接受randomAccessFileOrray
的构造函数是在部分模式下工作的,参见构造函数代码注释:
/**
* Reads and parses a pdf document. Contrary to the other constructors only the xref is read
* into memory. The reader is said to be working in "partial" mode as only parts of the pdf
* are read as needed.
* @param raf the document location
* @param ownerPassword the password or <CODE>null</CODE> for no password
* @throws IOException on error
*/
你想要什么是不可能的: 如果我理解正确,你想
PdfStamper
PdfStamper
并写入最终结果文件PdfReader
关于你的中心问题:
在我的应用程序中,阅读PDF文档已成为一项繁重的操作
根据您在每次迭代中操作PDF的方式,可能不需要解析整个现有PDF,例如,如果您每次仅操作一小部分PDF页面或仅附加新页面
如果是这种情况,您应该考虑使用<代码> PdfReader < /C> >构造器,该构造器只部分解析PDF并复制其余部分,而不需要解析资源。 PS:OP评论:
RandomAccessFileOrray中有什么?这是用来阅读部分文件的东西吗。它将文件读取时间从3秒大幅减少到300毫秒:) 是的,
PdfReader
接受randomAccessFileOrray
的构造函数是在部分模式下工作的,参见构造函数代码注释:
/**
* Reads and parses a pdf document. Contrary to the other constructors only the xref is read
* into memory. The reader is said to be working in "partial" mode as only parts of the pdf
* are read as needed.
* @param raf the document location
* @param ownerPassword the password or <CODE>null</CODE> for no password
* @throws IOException on error
*/
你想要什么是不可能的: 如果我理解正确,你想
PdfStamper
PdfStamper
并写入最终结果文件PdfReader
关于你的中心问题:
在我的应用程序中,阅读PDF文档已成为一项繁重的操作
根据您在每次迭代中操作PDF的方式,可能不需要解析整个现有PDF,例如,如果您每次仅操作一小部分PDF页面或仅附加新页面
如果是这种情况,您应该考虑使用<代码> PdfReader < /C> >构造器,该构造器只部分解析PDF并复制其余部分,而不需要解析资源。 PS:OP评论:
RandomAccessFileOrray中有什么?这是用来阅读部分文件的东西吗。它将文件读取时间从3秒大幅减少到300毫秒:) 是的,
PdfReader
接受randomAccessFileOrray
的构造函数是在部分模式下工作的,参见构造函数代码注释:
/**
* Reads and parses a pdf document. Contrary to the other constructors only the xref is read
* into memory. The reader is said to be working in "partial" mode as only parts of the pdf
* are read as needed.
* @param raf the document location
* @param ownerPassword the password or <CODE>null</CODE> for no password
* @throws IOException on error
*/
你想要什么是不可能的: 如果我理解正确,你想