【问题标题】:TallComponents.PDF.Document Error: "the document is corrupt, rebuilding failed"TallComponents.PDF.Document 错误:“文档已损坏,重建失败”
【发布时间】:2018-09-21 17:15:49
【问题描述】:

我收到异常“文档已损坏,重建失败”, 同时从 MemoryStream 实例化 TallComponents.PDF.Document。

byteResponse 很好。也就是说,文档没有损坏。 但是,我正在循环运行此方法以创建多个 PDF。

我错过了什么吗?我需要做任何额外的检查吗?

using (Stream stream = new MemoryStream(byteResponse, true))
{
     var pdf = new TallComponents.PDF.Document(stream);

【问题讨论】:

  • “byteResponse 很好” - 你是怎么测试的?
  • 是的,如果我们从具有 MIME 类型 application/pdf 的 Web 应用程序返回相同的字节数组,我们就可以浏览 pdf。但是,无法将相同的字节数组保存为 pdf 文档。我正在循环运行此方法以创建多个 PDF。关闭流或 TallComponent pdf 文档有什么问题吗?

标签: arrays pdf stream pdf-generation memorystream


【解决方案1】:

请设置stream.Position = 0;在创建 Tall Pdf 的实例之前。 您正在这样做,但在创建实例之后。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-21
    • 1970-01-01
    • 2016-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多