在充满 PDFtk 的 PDF 表单上复选框显示不一致

Inconsistent display of checkboxes on PDF form filled with PDFtk

我正在使用基于 PDFtk 的 pdf 表单 (https://github.com/jkraemer/pdf-forms) gem 在我的 rails 应用程序中填写 PDF 表单。文本字段按我预期的方式工作,但我的复选框字段没有。这些框在 Chrome 中显示良好,但在“预览”和“邮件”中复选框字段显示为空。

class FormsController < ApplicationController
require 'pdf_forms'
def acord25
  @policy = Policy.find(params[:id])
  pdftk = PdfForms.new('/usr/local/bin/pdftk')
  # find out the field names that are present in form.pdf
  pdftk.get_field_names 'lib/pdfs/acord25.pdf'

  # take form.pdf, set the 'foo' field to 'bar' and save the document to myform.pdf
  pdftk.fill_form '/lib/pdfs/acord25.pdf', "acord25.pdf", 
     "F[0].P1[0].Form_CompletionDate_A[0]" => @policy.dateIssued,
     "F[0].P1[0].Producer_FullName_A[0]" => @policy.client.broker.name,
     "F[0].P1[0].Producer_MailingAddress_LineOne_A[0]" => @policy.client.broker.company,
     "F[0].P1[0].Producer_MailingAddress_LineTwo_A[0]" => @policy.client.broker.address,
     "F[0].P1[0].Producer_ContactPerson_FullName_A[0]" => @policy.legalVesting,
     "F[0].P1[0].Producer_ContactPerson_PhoneNumber_A[0]" => @policy.client.broker.phone,
     "F[0].P1[0].Producer_FaxNumber_A[0]" => @policy.client.broker.fax,
     "F[0].P1[0].Producer_ContactPerson_EmailAddress_A[0]" => @policy.client.broker.email,
     "F[0].P1[0].NamedInsured_FullName_A[0]" => @policy.client.name,
     "F[0].P1[0].NamedInsured_MailingAddress_LineOne_A[0]" => @policy.client.address.titlecase,
     "F[0].P1[0].GeneralLiability_CoverageIndicator_A[0]" => 1,
     "F[0].P1[0].GeneralLiability_OccurrenceIndicator_A[0]" => 1,
     "F[0].P1[0].GeneralLiability_GeneralAggregate_LimitAppliesPerLocationIndicator_A[0]" => 1,
     "F[0].P1[0].Policy_PolicyNumberIdentifier_A[0]" => @policy.policyNumber,
     "F[0].P1[0].Policy_EffectiveDate_A[0]" => @policy.dateEffective,
     "F[0].P1[0].PolicyExpirationGeneral[0]" => @policy.term.dayEnd,
     "F[0].P1[0].Insurer_FullName_A[0]" => "Lexington Insurance Company",
     "F[0].P1[0].Insurer_NAICCode_A[0]" => 19437,
     "F[0].P1[0].Insurer_FullName_B[0]" => "Commerce & Industry Insurance Company",
     "F[0].P1[0].Insurer_NAICCode_B[0]" => 19410,
     "F[0].P1[0].Insurer_FullName_C[0]" => "Great American Insurance Company",
     "F[0].P1[0].Insurer_NAICCode_C[0]" => 37532,
     "F[0].P1[0].Insurer_FullName_D[0]" => "Admiral Insurance Company",
     "F[0].P1[0].Insurer_NAICCode_D[0]" => 24856,
     "F[0].P1[0].GeneralLiability_InsurerLetterCode_A[0]" => "A",
     "F[0].P1[0].GeneralLiability_EachOccurrence_LimitAmount_A[0]" => 1000000,
     "F[0].P1[0].GeneralLiability_FireDamageRentedPremises_EachOccurrenceLimitAmount_A[0]" => 50000,
     "F[0].P1[0].GeneralLiability_MedicalExpense_EachPersonLimitAmount_A[0]" => "Excluded",
     "F[0].P1[0].GeneralLiability_PersonalAndAdvertisingInjury_LimitAmount_A[0]" => 1000000,
     "F[0].P1[0].GeneralLiability_GeneralAggregate_LimitAmount_A[0]" => 2000000,
     "F[0].P1[0].GeneralLiability_ProductsAndCompletedOperations_AggregateLimitAmount_A[0]" => 2000000,
     "F[0].P1[0].Vehicle_InsurerLetterCode_A[0]" => "A",
     "F[0].P1[0].Vehicle_HiredAutosIndicator_A[0]" => 1,
     "F[0].P1[0].Vehicle_NonOwnedAutosIndicator_A[0]" => 1,
     "F[0].P1[0].Policy_PolicyNumberIdentifier_B[0]" => @policy.policyNumber,
     "F[0].P1[0].Policy_EffectiveDate_B[0]" => @policy.dateEffective,
     "F[0].P1[0].Policy_ExpirationDate_B[0]" => @policy.term.dayEnd,
     "F[0].P1[0].Vehicle_CombinedSingleLimit_EachAccidentAmount_A[0]" => 1000000,
     "F[0].P1[0].ExcessUmbrella_InsurerLetterCode_A[0]" => "B",
     "F[0].P1[0].ExcessUmbrella_OccurrenceIndicator_A[0]" => 1,
     "F[0].P1[0].ExcessUmbrella_DeductibleIndicator_A[0]" => 1,
     "F[0].P1[0].ExcessUmbrella_Umbrella_DeductibleOrRetentionAmount_A[0]" => @policy.coverages.first.deductibleOcc,
     "F[0].P1[0].Policy_PolicyNumberIdentifier_D[0]" => @policy.policyNumber,
     "F[0].P1[0].Policy_EffectiveDate_D[0]" => @policy.dateEffective,
     "F[0].P1[0].Policy_ExpirationDate_D[0]" => @policy.term.dayEnd,
     "F[0].P1[0].ExcessUmbrella_Umbrella_EachOccurrenceAmount_A[0]" => 10000000,
     "F[0].P1[0].ExcessUmbrella_Umbrella_AggregateAmount_A[0]" => 10000000

     send_file("#{Rails.root}/acord25.pdf", filename: "#{@policy.client.name} - #{@policy.carrier.name} - #{@policy.policyNumber} (#{Time.now}).pdf", type: "application/vnd.ms-excel")
end
end

TL;DR:选中的框显示在 Chrome 中,但不显示在预览或邮件中。

对于可能出现的问题的任何帮助或线索,我深表感谢。谢谢!

原来 PDF 表单已损坏。必须重新创建表单,而不是 PDFTK 问题。