mirror of
https://github.com/docusealco/docuseal
synced 2026-11-04 22:42:32 -05:00
process malformed PDF
This commit is contained in:
1 parent
3dd0ba6b0b
commit
5845b5bdfd
1 file changed
+15
-3
@@ -243,7 +243,6 @@ module Submissions
|
||||
|
||||
results + [images_pdf_result]
|
||||
end
|
||||
# rubocop:enable Metrics
|
||||
|
||||
def save_pdf(pdf:, submitter:, pkcs:, tsa_url:, uuid:, name:)
|
||||
io = StringIO.new
|
||||
@@ -265,10 +264,23 @@ module Submissions
|
||||
sign_params[:signature_size] = 10_000
|
||||
end
|
||||
|
||||
pdf.sign(io, write_options: { validate: false }, **sign_params)
|
||||
begin
|
||||
pdf.sign(io, write_options: { validate: false }, **sign_params)
|
||||
rescue HexaPDF::MalformedPDFError => e
|
||||
Rollbar.error(e) if defined?(Rollbar)
|
||||
|
||||
pdf.sign(io, write_options: { validate: false, incremental: false }, **sign_params)
|
||||
end
|
||||
else
|
||||
pdf.write(io, incremental: true, validate: false)
|
||||
begin
|
||||
pdf.write(io, incremental: true, validate: false)
|
||||
rescue HexaPDF::MalformedPDFError => e
|
||||
Rollbar.error(e) if defined?(Rollbar)
|
||||
|
||||
pdf.write(io, incremental: false, validate: false)
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics
|
||||
|
||||
ActiveStorage::Attachment.create!(
|
||||
blob: ActiveStorage::Blob.create_and_upload!(io: StringIO.new(io.string), filename: "#{name}.pdf"),
|
||||
|
||||
Reference in new issue
Block a user