我正在尝试使用ITextSharp在pdf文档中旋转各种页面 . 它似乎正在发挥作用,因为当我在adobe中打开时,一切看起来都很好 . 但是,当尝试在itextsharp中重新打开时,会抛出各种异常 . 我可以告诉文档有什么用处,因为adobe总是询问我是否要在打开使用itextsharp操作的文档时保存更改,这表明它修复了损坏 .
疯狂的是我甚至不需要对文档进行任何操作,只需创建一个新的压模并关闭它 . 下面是代码,它被剥离到仍然破坏文档的程度 .
有任何想法吗?
这是我的代码
Dim byteArray = IO.File.ReadAllBytes(filename)
Using reader = New iTextSharp.text.pdf.PdfReader(byteArray)
Using stamper = New iTextSharp.text.pdf.PdfStamper(reader, New IO.FileStream(filename, IO.FileMode.OpenOrCreate))
'I don't even have to do anything for it to corrupt, just use a stamper
stamper.Close()
End Using
reader.Close()
End Using
1 回答
我解决了这个问题 . 我换了这个
至
它现在工作正常 . 我不确定为什么,但如果有其他人有这个问题,我希望这有帮助 .