lib/hexapdf/cli/form.rb in hexapdf-0.32.2 vs lib/hexapdf/cli/form.rb in hexapdf-0.33.0
- old
+ new
@@ -95,20 +95,20 @@
end
def execute(in_file, out_file = nil) #:nodoc:
maybe_raise_on_existing_file(out_file) if out_file
if (@fill || @flatten) && !out_file
- raise "Output file missing"
+ raise Error, "Output file missing"
end
with_document(in_file, password: @password, out_file: out_file,
incremental: @incremental) do |doc|
if doc.acro_form[:XFA]
$stderr.puts "Warning: Unsupported XFA form detected, some things may not work correctly"
end
if !doc.acro_form
- raise "This PDF doesn't contain an interactive form"
+ raise Error, "This PDF doesn't contain an interactive form"
elsif out_file
doc.acro_form[:NeedAppearances] = @need_appearances unless @need_appearances.nil?
if @fill || !@flatten
if @template
fill_form_with_template(doc)
@@ -218,11 +218,11 @@
def fill_form_with_template(doc)
data = parse_template
form = doc.acro_form
data.each do |name, value|
field = form.field_by_name(name)
- raise "Field '#{name}' not found in input PDF" unless field
+ raise Error, "Field '#{name}' not found in input PDF" unless field
apply_field_value(field, value)
end
end
# Parses the data from the given template file.
@@ -266,13 +266,13 @@
value
end
when :radio_button
field.field_value = value.to_sym
else
- raise "Field type #{field.concrete_field_type} not yet supported"
+ raise Error, "Field type #{field.concrete_field_type} not yet supported"
end
rescue StandardError
- raise "Error while setting '#{field.full_field_name}': #{$!.message}"
+ raise Error, "Error while setting '#{field.full_field_name}': #{$!.message}"
end
# Iterates over all non-push button fields in page order. If a field appears on multiple
# pages, it is only yielded on the first page.
def each_field(doc) # :yields: page, page_index, field