mirror of
https://github.com/docusealco/docuseal
synced 2026-11-05 14:42:33 -05:00
add tool to merge pdf files
This commit is contained in:
1 parent
286b8d7067
commit
ab49af9bcb
3 files changed
+36
No files matched your search
@@ -26,4 +26,19 @@ module PdfUtils
|
||||
|
||||
decrypted_io.tap(&:rewind).read
|
||||
end
|
||||
|
||||
def merge(files)
|
||||
merged_pdf = HexaPDF::Document.new
|
||||
|
||||
files.each do |file|
|
||||
pdf = HexaPDF::Document.new(io: file)
|
||||
pdf.pages.each { |page| merged_pdf.pages << merged_pdf.import(page) }
|
||||
end
|
||||
|
||||
merged_content = StringIO.new
|
||||
merged_pdf.write(merged_content)
|
||||
merged_content.rewind
|
||||
|
||||
merged_content
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user