Did you generate this PDF on Windows? People have mentioned Windows
issues on this list lately.
That is a lot of code. Please try removing parts of the code,
generating the file and opening it, until you get a minimal file that
has the error.
> --
>
> You received this message because you are subscribed to the Google Groups "Prawn" group.
> To post to this group, send email to
prawn...@googlegroups.com.
> To unsubscribe from this group, send email to
prawn-ruby+...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/prawn-ruby?hl=en.
>
>
>
> pdf.instance_variable_set("@left_margin", 20)
> pdf.instance_variable_set("@right_margin", 20)
> pdf.instance_variable_set("@top_margin", 12)
> pdf.instance_variable_set("@bottom_margin", 12)
> pdf.instance_variable_set("@page_size", 'A4')
> pdf.instance_variable_set("@compress", true)
>
> border_color = "97b4d7"
> back_color = "cde0f7"
>
> web_path = "/gallery/#{Setting.actual_setting.sitename}/Setting/#{
Setting.actual_setting.id}/"
> pdf.fill_color "0b0b0b"
> pdf.stroke_color "0b0b0b"
> pdf.padded_box(20) do
> pdf.stroke_bounds
>
> if File.file?("#{RAILS_ROOT}/public#{web_path}images/barra_header.jpg")
> pdf.image "#{RAILS_ROOT}/public#{web_path}images/barra_header.jpg", :fit => [pdf.bounds.width, 107]
> end
>
> if File.file?("#{RAILS_ROOT}/public#{web_path}images/barra_footer.jpg")
> move_by = pdf.cursor()
> pdf.move_down(move_by - 31.5)
> pdf.image "#{RAILS_ROOT}/public#{web_path}images/barra_footer.jpg", :fit => [pdf.bounds.width() -1, 107], :position => :center
> pdf.move_up(move_by)
> end
>
> pdf.rectangle [0,pdf.cursor], (pdf.bounds.width)-1, 50
> pdf.fill_and_stroke
> pdf.move_down(10)
>
> pdf.fill_color "ffffff"
> company = Setting.actual_setting.company
> pdf.text company.full_name, :align => :center, :size => 8
> if !company.address.nil?
> pdf.text "#{company.address.street}, #{company.address.number} - #{company.address.zip} - #{company.address.town}#{(company.address.province != "") ? "(#{company.address.province})" : ""} #{company.address.country}", :align => :center, :size => 8
> end
> pdf.text "#{_("C.F.")} #{company.fiscal_code} - #{_("P.Iva")} #{company.vat_code}", :align => :center, :size => 8
> pdf.text "#{_("Tel.")} #{(company.phone_numbers.nil? or company.phone_numbers.empty?) ? "" : company.phone_numbers[0].number} - em@il : #{company.email}", :align => :center, :size => 8
>
> pdf.move_down(20)
>
> pdf.fill_color "0b0b0b"
> if @detail.proforma
> pdf.text _("FATTURA PROFORMA"), :at => [10, pdf.cursor], :size => 9
> else
> pdf.text %(#{(@detail.receipt ? _("RICEVUTA N°") : _("FATTURA N°"))}), :at => [10, pdf.cursor], :size => 9
> pdf.fill_color back_color
> pdf.stroke_color border_color
> pdf.rectangle [80, (pdf.cursor) + (pdf.font.height) -3 ], 30, (pdf.font.height) +2
> pdf.fill_and_stroke
> pdf.fill_color "0b0b0b"
> pdf.text @detail.code, :at => [85, pdf.cursor], :size => 9
> end
>
> pdf.move_down(30)
> pdf.text _("Date"), :at => [10, pdf.cursor], :size => 9
> pdf.fill_color back_color
> pdf.stroke_color border_color
> pdf.rectangle [80, (pdf.cursor) + (pdf.font.height) -3 ], 80, (pdf.font.height) +2
> pdf.fill_and_stroke
> pdf.fill_color "0b0b0b"
> pdf.text @detail.date.strftime("%d/%m/%Y"), :at => [85, pdf.cursor], :size => 9
>
> pdf.move_up(30)
> pdf.text _("Spettabile"), :at => [240, pdf.cursor], :size => 9
> pdf.fill_color back_color
> pdf.stroke_color border_color
> pdf.rectangle [300, (pdf.cursor) + (pdf.font.height) -3 ], 200, 50
> pdf.fill_and_stroke
> pdf.fill_color "0b0b0b"
>
> pdf.move_up(5)
>
> pdf.span(180, :position => 325) do
> address = (!@detail.company.billing_address.nil? ? @detail.company.billing_address : @detail.company.address )
> pdf.text %(#{@detail.company.full_name}), :size => 8
> pdf.text %(#{address.street}, #{address.number} #{address.internal}), :size => 8
> pdf.text %(#{address.zip} - #{address.town}#{(address.province != "") ? "(#{address.province})" : ""} #{address.country}), :size => 8
> pdf.text %(#{_("C.F.")} : #{@detail.company.fiscal_code} - #{_("P.Iva")} : #{@detail.company.vat_code}), :size => 8
> end
>
> pdf.move_down(60)
> righe = Array.new
> total = 0
> @detail.free_lines.each do |free_line|
> total = total + free_line.total
> righe << [free_line.quantity, free_line.description, %(€ #{format("%.2f",free_line.price)}), %(€ #{format("%.2f",free_line.total)})]
> end
>
> pdf.stroke_color "0b0b0b"
> pdf.fill_color "0b0b0b"
> pdf.table righe,
> :border_style => :grid,
> :row_colors => [ back_color, "FFFFFF"],
> :headers => [_("Q.Tà"), _("Descrizione"), _("IMP. UNIT"), _("IMP. TOT")],
> :header_color => '97b4d7',
> :font_size => 6,
> :align => { 0 => :center, 1 => :left, 2 => :right, 3 => :right },
> :column_widths => { 0 => 40, 1 => 355, 2 => 50, 3 => 50 },
> :position => pdf.bounds.width - 505
>
>
> righe = Array.new
> righe << [_("Totale"), %(€ #{format("%.2f",total)})]
> righe << [%(#{_("Iva")} #{@detail.vatrate.to_s}%), %(€ #{format("%.2f",(total / 100) * @detail.vatrate)}) ]
> righe << [%(#{_("Totale")} + #{_("Iva")}), %(€ #{format("%.2f",((total / 100) * @detail.vatrate) + total)}) ]
> if @detail.ritenuta
> righe << [%(#{_("Ritenuta di acconto 20% su")} € #{total}), %(€ #{format("%.2f",((total / 100) * @detail.vatrate))}) ]
> righe << [_("Netto da pagare"), %(€ #{format("%.2f",total)})]
> end
>
>
> pdf.table righe,
> :border_style => :grid,
> :font_size => 6,
> :align => { 0 => :left, 1 => :right },
> :column_widths => { 0 => 120, 1 => 50 },
> :position => pdf.bounds.width - 180
> if @detail.proforma
> pdf.move_down(20)
> pdf.text _("Nota spese non valida ai fini IVA. La fattura verrà emessa al momento del pagamento."),:at => [10, pdf.cursor], :size => 5
> end
> pdf.move_down(pdf.cursor() - 70)
>
> pdf.text _("Modalità di pagamento"),:at => [10, pdf.cursor], :size => 9
> pdf.fill_color back_color
> pdf.stroke_color border_color
> pdf.rectangle [130, (pdf.cursor) + (pdf.font.height) -3 ], pdf.bounds.width - 140, 30
> pdf.fill_and_stroke
> pdf.fill_color "0b0b0b"
> pdf.move_up(6)
> pdf.span( pdf.bounds.width - 165, :position => 160) do
> pdf.text @detail.payment_type.description, :size => 9
> if !@detail.payment_type.bank_account.nil?
> pdf.text %(#{@detail.payment_type.bank_account.bank_name}#{
> (@detail.payment_type.bank_account.address.nil? ? "" :
> %(#{@detail.payment_type.bank_account.address.street}, #{@detail.payment_type.bank_account.address.number} #{@detail.payment_type.bank_account.address.internal} - #{@detail.payment_type.bank_account.address.zip} - #{@detail.payment_type.bank_account.address.town}#{(@detail.payment_type.bank_account.address.province != "") ? "(#{@detail.payment_type.bank_account.address.province})" : ""} #{@detail.payment_type.bank_account.address.country}) )
> } - #{_("IBAN")} : #{@detail.payment_type.bank_account.iban}), :size => 9
> end
> end
> end
>
> if @detail.proforma
> filename = %(#{_("proforma").camelcase}_#{@detail.date.strftime("%d_%m_%Y")}.pdf)
> elsif @detail.receipt
> filename = %(#{_("ricevuta").camelcase}_#{@detail.code.to_s}_#{@detail.date.strftime("%d_%m_%Y")}.pdf)
> else
> filename = %(#{_("fattura").camelcase}_#{@detail.code.to_s}_#{@detail.date.strftime("%d_%m_%Y")}.pdf)
> end
> FileUtils.mkdir_p "#{RAILS_ROOT}/public/gallery/#{Setting.actual_setting.sitename}/Company/#{@detail.company.id.to_s}/attachments"
> pdf.render_file "#{RAILS_ROOT}/public/gallery/#{Setting.actual_setting.sitename}/Company/#{@detail.company.id.to_s}/attachments/#{filename}"
>