Skip to content

Instantly share code, notes, and snippets.

@allefgomes
Last active April 4, 2021 22:22
Show Gist options
  • Save allefgomes/b78da8ca10744955be23d8116af3189d to your computer and use it in GitHub Desktop.
Save allefgomes/b78da8ca10744955be23d8116af3189d to your computer and use it in GitHub Desktop.
Merge all pdfs
require 'combine_pdf'
pdf = CombinePDF.new
# Verify all files
p '##################### Search files #####################'
Dir.entries(Dir.pwd).each do |file|
# Merge files
pdf << CombinePDF.load(file) unless File.extname(file) != ".pdf"
end
# Save file
pdf.save "name_of_my_pdf.pdf"
p '############################## Saved File in Dir.pwd ##############################'
@bergpb
Copy link

bergpb commented Aug 27, 2018

sensacional, esse ruby é bom msm hehehe.

@israelhudson
Copy link

Great code. Congratulations!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment