複数のxps、oxpsのファイルをpdf化するバッチと複数のpdfを結合するバッチ

ghostscriptのサイト
https://www.ghostscript.com/

ダウンロードしてパスを通す必要があるもの

xps、oxpsをpdf化するためにダウンロードするもの
https://www.ghostscript.com/releases/gxpsdnld.html
から
GNU Affero General Public License
の列に有るWindows版のものをダウンロードし、展開しパスを通す

pdfファイルを結合するためにダウンロードするもの
https://www.ghostscript.com/releases/gsdnld.html
から
GNU Affero General Public License
の列に有るWindows版のものをダウンロードし、インストールしパスを通す

使い方
下記oxps2pdf.batとcombinepdf.batのコードをコピペ、保存する。
xps、oxpsのファイルのあるフォルダーへoxps2pdf.batとcombinepdf.batを置きます。

oxps2pdf.batをダブルクリックで処理開始し、pdf化されます。

combinepdf.batの使い方

1つめの引数を、結合後のpdf名とし、それ以降が結合対象pdf名です。少数であれば空白区切りで並べていきます。
combinepdf.bat result.pdf 01_ab.pdf 02_cd.pdf

結合対象pdf名にはワイルドカードが使えます。(ファイル名の命名が規則的であれば、ある程度は順番に結合されるようです)
combinepdf.bat result.pdf 0*_*.pdf

----------------------------------------------------------------------------------------------------
oxps2pdf.bat
----------------------------------------------------------------------------------------------------
::This software includes the work that is distributed in the Apache License 2.0.
::https://www.apache.org/licenses/LICENSE-2.0

@echo off

for %%A in (*.xps *.oxps) do (
	gxpswin64  -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=%%~nA.pdf %%A
)

----------------------------------------------------------------------------------------------------
combinepdf.bat
----------------------------------------------------------------------------------------------------
::This software includes the work that is distributed in the Apache License 2.0.
::https://www.apache.org/licenses/LICENSE-2.0

@echo off
setlocal enableDelayedExpansion

for %%A in (%*) do (
	if not defined files (
		set files=%%A
	) else (
		set files=!files! %%A
	)
)

gswin64c -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=%files%

endlocal

コメントする

メールアドレスが公開されることはありません。 が付いている欄は必須項目です