LoginSignup
6
7

More than 5 years have passed since last update.

LaTeXで作ったPDFファイルをPDF/A準拠にする(Mac)

Last updated at Posted at 2018-06-23

PDF/Aを作りたい

LaTexを使って書いた書類をdvipdfmxなどでPDFに変換することがある.その場合に出力されたPDFファイルは大抵問題なく使えるが,たまにPDFファイルが特定の規格に準拠していることが求められる場合がある.

論文原稿がPDF/A準拠していることを求められた.Adobe Acrobatなどの有償ソフトウェアを使えばできるが,今回はオープンなソフトウェアでPDF/Aへの変換と準拠チェックを行う.

PDFファイルのPDF/A形式への変換手順

準備

Ghostscriptでできる.Homebrewでインストールされていることを前提にする.なければbrew install ghostscript.

PDFを作る

Illustratorなどで作成する.今回はカラーモードをRGBで作成する.ICCプロファイルはAdobeRGB1998を指定する.参考ページ

Ghostscriptの設定ファイルを作成する

Ghostscriptがインストールされているディレクトリに設定ファイルの雛形が置いてある.Homebrewでインストールしたので/usr/local/Cellar/ghostscript/9.23/share/ghostscript/9.23/lib/PDFA_def.psにあった.9.23はバージョンによって異なるので注意.これを適当な場所にコピーして保存.

$ cd <some-directory>
$ cp /usr/local/Cellar/ghostscript/9.23/share/ghostscript/9.23/lib/PDFA_def.ps .

PDFA_def.psを編集.

%!
% This is a sample prefix file for creating a PDF/A document.
% Feel free to modify entries marked with "Customize".
% This assumes an ICC profile to reside in the file (ISO Coated sb.icc),
% unless the user modifies the corresponding line below.

% Define entries in the document Info dictionary :
/ICCProfile (AdobeRGB1998.icc) % Customise
def

[ /Title (Title)       % Customise
  /DOCINFO pdfmark

% Define an ICC profile :

[/_objdef {icc_PDFA} /type /stream /OBJ pdfmark
[{icc_PDFA}
<<
  /N currentpagedevice /ProcessColorModel known {
    currentpagedevice /ProcessColorModel get dup /DeviceGray eq
    {pop 1} {
      /DeviceRGB eq
      {3}{4} ifelse
    } ifelse
  } {
    (ERROR, unable to determine ProcessColorModel) == flush
  } ifelse
>> /PUT pdfmark
[{icc_PDFA} ICCProfile (r) file /PUT pdfmark

% Define the output intent dictionary :

[/_objdef {OutputIntent_PDFA} /type /dict /OBJ pdfmark
[{OutputIntent_PDFA} <<
  /Type /OutputIntent             % Must be so (the standard requires).
  /S /GTS_PDFA1                   % Must be so (the standard requires).
  /DestOutputProfile {icc_PDFA}            % Must be so (see above).
  /OutputConditionIdentifier (sRGB)      % Customize
>> /PUT pdfmark
[{Catalog} <</OutputIntents [ {OutputIntent_PDFA} ]>> /PUT pdfmark

/ICCProfile (AdobeRGB1998.icc) % Customiseの部分が重要.

変換

以下のようなBashスクリプトで変換した.


#!/bin/bash

OUT=<path-to-output-file>.pdf
IN=<path-to-input-file>.pdf

# PS should be absolute path
PS=<path-to-PDFA_def.ps> 

gs -dPDFA=1 \
    -dBATCH \
    -dNOPAUSE \
    -dNOOUTERSAVE \
    -sDEVICE=pdfwrite \
    -sOutputICCProfile=AdobeRGB1998.icc \
    -o ${OUT} \
    ${PS} \
    ${IN}

変換されたファイルがPDF/Aに準拠しているかどうかの判定

veraPDFが使える.READMEにしたがってインストールをすればverapdf-gui, verapdfが使えるようになる. verapdf-guiはGUIのツールで,以下のようにファイルを選んでExecuteボタンを押せば結果を見ることができる.

PDF_A_Conformance_Checker_と_「LaTeXで作ったPDFファイルをPDF_A準拠にする_Mac_」を編集_-_Qiita.png

6
7
0

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
6
7