2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Python:TIFFをPDFに変換する

Posted at

経緯

会社のFAX複合機は勝手にTIFFを指定のフォルダに保存してくれるのですが、
TIFFなのでPDFにしたかったので書いてみました。

使用環境

インタープリター:Python3.6
使用ライブラリ:os

そのほかアプリ:Tiff2Pdf
配布元:https://bitmiracle.com/libtiff/
ライセンスおよび使用方法:https://bitmiracle.github.io/libtiff.net/

コード

Tiff2PDF
# !/usr/bin/env python
# -*- coding: utf-8 -*-
import os

# 保存元のパス:I:/000.FAX/受信控
# 出力先のパス:C:/FAX_PDF/
# 上記は任意にて変更してください。

# パスの指定し取得したファイル一覧をまわす
files = os.listdir("I:/000.FAX/受信控") 

for BFR_LIST in files:
    # PDFコンバーターを用意
    cmd_file = "C:/tiff2pdf\Tiff2Pdf.exe"
    command = cmd_file

    # 変換後のPDF名に置き換え
    AFT_LIST = BFR_LIST.replace('.tif', '.pdf')

    #指定フォルダにファイルが存在している場合はスキップ
    if bool(os.path.isfile("C:/FAX_PDF/"+AFT_LIST )) is True:
        continue

    #  PDFコンバーター引数渡し
    command += " " + "-o" + " C:/FAX_PDF/" + AFT_LIST+ " I:/000.FAX/受信控/" + BFR_LIST

    # PDFでない場合は変換をスキップ
    if bool(AFT_LIST.endswith("pdf")) is False:
        continue

    #コマンド確認用
    #print (command)

    # PDFの変換を実行
    os.system(command)
    command=[]

2
1
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?