Last active
September 30, 2022 01:06
-
-
Save milnak/debe5f29ed0d97c4264faf50c6bd20f1 to your computer and use it in GitHub Desktop.
Burst a PDF Document into Single Pages using qpdf - https://github.com/qpdf/qpdf
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
@ECHO OFF | |
REM Burst a PDF Document into Single Pages using qpdf - https://github.com/qpdf/qpdf | |
SETLOCAL | |
IF "%~1"=="" ( | |
ECHO PDF_filename | |
ECHO Example: %~nx0 document.pdf | |
GOTO :EOF | |
) | |
REM Get script directory without trailing slash. | |
set _SCRIPT_DIR=%~dp0 | |
set SCRIPT_DIR=%_SCRIPT_DIR:~0,-1% | |
REM Change this to where qpdf.exe is installed to. | |
set QPDF_DIR=%SCRIPT_DIR%\qpdf\bin | |
ECHO. | |
ECHO "%~1" --^> "%~n1_nn.pdf" | |
ECHO. | |
set OUTPUT_DIR=BURST | |
if not exist %OUTPUT_DIR% md %OUTPUT_DIR% | |
set OUTPUT_FN=%~n1 | |
REM --pages 1,3,5-9,15-12 | |
%QPDF_DIR%\qpdf.exe --verbose --split-pages "%~1" "%OUTPUT_DIR%\%OUTPUT_FN% [%%d].pdf" | |
ECHO. | |
ECHO Output is in %OUTPUT_DIR% | |
ECHO. | |
ECHO To combine: | |
ECHO dir /b /on *.pdf ^| %QPDF_DIR%\qpdf.exe --verbose --empty --pages @- 1-z -- "%OUTPUT_FN%.pdf" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment