7 列の表を含む複数ページの PDF を作成しています。
開発用コンピューター (Mac OS X 10.8、ruby 1.9.2、Rails 3.2.6) で PDF を作成すると、正しくダウンロードされ、レンダリングされます。
ステージング サーバーで PDF を作成すると、プレビューで表示しようとすると、「破損しているか、プレビューが認識しないファイル形式を使用している可能性があります。」というエラー メッセージが表示されます。
本番サーバーで PDF を作成すると、正しく動作します。
テーブル内のすべての列を削除し、一度に 1 つずつ追加して問題の原因を確認しようとしましたが、明らかな原因はありません。
テーブルの幅の問題かもしれないと思って、横向きに変更してフォントサイズを小さくしようとしましたが、それでも違いはありません。
実稼働サーバーでも動作しますが、そこでも発生し始めた場合に備えて、その根底に到達したいと考えています。また、ステージングでテストできない場合、クライアントは更新をサインオフできません。
ここにコードがあります
@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
すべてのエントリをハードコードされた 1 文字に置き換えても、クラッシュが発生します。
更新: 破損した PDF ファイルをテキスト ビューアーで表示すると、ファイルが途中で停止し、末尾が欠けているように見えるため、どの PDF ビューアーにも表示されません。