Manipulasi dokumen PDF dengan Ghostscript (1)

Beberapa waktu yang lalu saya diberikan tugas untuk editing dokumen proceeding berupa berkas PDF. Editing yang dimaksud adalah memotong dokumen per makalah (ekstraksi halaman). Pada awalnya saya menggunakan okular (aplikasi document viewer) untuk proses ekstraksi, dengan cara print dokumen ke file.pdf. Memang agak ribet, namun sekarang saya menemukan cara paling enak dan mudah. Dengan command-line menggunakan Ghostscript! :D

Perintah yang saya gunakan untuk proses ekstraksi adalah sebagai berikut:

gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=<halaman awal> -dLastPage=<halaman akhir> -sOutputFile=<output> <input>

Sebagai contoh:

┌─[archlinux]─[~]
└─[$] gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=1 -dLastPage=6 -sOutputFile=cover.pdf Proceeding_Seminar_Nasional_Aljabar.pdf

Log:

GPL Ghostscript 9.06 (2012-08-08)
Copyright (C) 2012 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
**** Warning: Outline has invalid link that was discarded.
Processing pages 1 through 6.
Page 1
Substituting font Helvetica-Bold for Arial-BoldMT.
Loading NimbusSanL-Bold font from /usr/share/ghostscript/9.06/Resource/Font/NimbusSanL-Bold... 4069176 2519499 3523136 2192466 3 done.
Substituting font Helvetica for ArialMT.
Loading NimbusSanL-Regu font from /usr/share/ghostscript/9.06/Resource/Font/NimbusSanL-Regu... 4069176 2572416 3543320 2069799 3 done.
Substituting font Helvetica-Bold for TrebuchetMS-Bold.
Substituting font Times-Bold for TimesNewRomanPS-BoldMT.
Loading NimbusRomNo9L-Medi font from /usr/share/ghostscript/9.06/Resource/Font/NimbusRomNo9L-Medi... 4117588 2731570 4290128 2668922 3 done.
Substituting font Helvetica for TrebuchetMS.
Page 2
Substituting font Helvetica for ArialMT.
Substituting font Helvetica-Bold for Arial-BoldMT.
Substituting font Helvetica-Bold for TrebuchetMS-Bold.
Substituting font Times-Bold for TimesNewRomanPS-BoldMT.
Substituting font Helvetica for TrebuchetMS.
Page 3
Page 4
Substituting font Times-Roman for TimesNewRomanPSMT.
Loading NimbusRomNo9L-Regu font from /usr/share/ghostscript/9.06/Resource/Font/NimbusRomNo9L-Regu... 4148840 2687014 5362948 3964106 3 done.
Substituting font Times-Bold for TimesNewRomanPS-BoldMT.
Page 5
**** Warning: Link annotation points out of the document page range.
**** Warning: Link annotation points out of the document page range.
**** Warning: Link annotation points out of the document page range.
**** Warning: Link annotation points out of the document page range.
**** Warning: Link annotation points out of the document page range.
**** Warning: Link annotation points out of the document page range.
**** Warning: Link annotation points out of the document page range.
**** Warning: Link annotation points out of the document page range.
**** Warning: Link annotation points out of the document page range.
**** Warning: Link annotation points out of the document page range.
**** Warning: Link annotation points out of the document page range.
**** Warning: Link annotation points out of the document page range.
Page 6
**** Warning: Link annotation points out of the document page range.
**** Warning: Link annotation points out of the document page range.
**** Warning: Link annotation points out of the document page range.
**** Warning: Link annotation points out of the document page range.
**** Warning: Link annotation points out of the document page range.
**** Warning: Link annotation points out of the document page range.
**** Warning: Link annotation points out of the document page range.
Substituting font Times-Bold for TimesNewRomanPS-BoldMT.

**** This file had errors that were repaired or ignored.
**** The file was produced by:
**** >>>> Acrobat Distiller 7.0 (Windows) <<<<
**** Please notify the author of the software that produced this
**** file that it does not conform to Adobe's published PDF
**** specification.

Properties dokumen hasil ekstraksi:

Perintah diatas memang agak sedikit ribet, namun jika dibuatkan suatu fungsi bash tentunya akan lebih mudah :-)

Referensi: manual gs (Ghostscript), pdfghostscript

=-=-=-=-=
Powered by Blogilo

About these ads

One thought on “Manipulasi dokumen PDF dengan Ghostscript (1)

  1. Pingback: Manipulasi dokumen PDF dengan Ghostscript (2) « [go2n@buglink:~] $

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s