我正在创建一个包含7列表格的多页PDF .

当我在我的开发计算机上创建PDF(Mac OS X 10.8,ruby 1.9.2,Rails 3.2.6)时,它会正确下载和渲染 .

如果我在登台服务器上创建PDF,当我尝试在预览中查看它时会收到以下错误消息:“它可能已损坏或使用预览无法识别的文件格式” .

如果我在 生产环境 服务器上创建PDF,它可以正常工作 .

我已经尝试删除表中的所有列并一次一个地添加它们以查看哪个列导致了问题,但这没有明显的原因 .

认为它可能是一个表宽度问题,我已经尝试将其更改为横向并减小字体大小但仍然没有区别 .

即使它在 生产环境 服务器上运行,我也希望它能够在它开始发生的时候到达底层 . 如果无法在升级时测试,我的客户也无法签署更新 .

这是代码

@locations.each do |location|
    modules_marked = 10 # this is calculated in the actual code
    exams_marked = 10 # this is calculated in the actual code

    total_delegates += CourseDelegate.for_location(location).count
    total_modules += modules_marked
    total_exams += exams_marked

    entry = []
    entry << location.name[0..5]
    entry << location.division.name
    entry << location.operating_unit_number
    entry << location.purchase_order
    entry << CourseDelegate.for_location(location).count
    entry << modules_marked
    entry << exams_marked

    entries << entry
end

table(entries, :header => true, :width => bounds.width) do 
    row(0).font_style = :bold
    row(entries.count - 1).font_style = :bold

    cells.border_width = 0.1
    cells.border_color = "808080"

    cells.size = 8
    column(1).width = 60
    column(2).width = 60
    column(3).width = 50
    column(4).width = 50
    column(5).width = 50
    column(6).width = 50
    column(0).align = :left
    column(1).align = :left
    column(4).align = :center
    column(5).align = :center
    column(6).align = :center
end

即使用硬编码的单个字母替换所有条目仍然会导致崩溃 .

更新:我应该提一下,当我在文本查看器中查看损坏的PDF文件时,看起来好像文件只是在中途停止并且缺少结束,这就是为什么它没有在任何PDF查看器中显示 .