Created
August 26, 2020 00:23
-
-
Save bdkosher/118be3cb9aa95c12a58c54c1c8a574c4 to your computer and use it in GitHub Desktop.
Adobe's not getting $14 from me just so I can merge some PDF pages together
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab(group='org.apache.pdfbox', module='pdfbox', version='2.0.21') | |
import org.apache.pdfbox.multipdf.PDFMergerUtility | |
import org.apache.pdfbox.io.MemoryUsageSetting | |
def dir = new File('C:\\Users\\Joe\\Documents\\pdfs') | |
def merger = new PDFMergerUtility(); | |
(1..3).each { merger.addSource(new File(dir, "document_page${it}.pdf")) } | |
merger.destinationFileName = new File(dir, "document.pdf").absolutePath | |
merger.mergeDocuments(MemoryUsageSetting.setupTempFileOnly()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment