LoginSignup
3

More than 5 years have passed since last update.

pdfの注釈を扱いたい

Posted at

白紙のPDFを自由に作ってそこに転写するか、
注釈自体を保管しておきたい。
結果、unidocで文字コードが難しいことがわかったら周りの沼が深くなってて動けなくなった

概要てさぐり

CPDF:メッチャ多機能なPDFのコマンドライン・ツール | PDF
http://pdf-file.nnn2.com/?p=892

macOS でPDF分割(コマンドライン編) - ながいものには、まかれたくない
https://a244.hateblo.jp/entry/2017/03/30/060000

CPDF:オペレーションの解説 | PDF
http://pdf-file.nnn2.com/?p=1025

オブジェクト ストリーム pdf 注釈 - Google 検索
https://www.google.co.jp/search?num=100&safe=off&ei=-af-WtLSG4Sn0gT1p7noAQ&q=%E3%82%AA%E3%83%96%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88+%E3%82%B9%E3%83%88%E3%83%AA%E3%83%BC%E3%83%A0+pdf+%E6%B3%A8%E9%87%88&oq=%E3%82%AA%E3%83%96%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88+%E3%82%B9%E3%83%88%E3%83%AA%E3%83%BC%E3%83%A0+pdf+%E6%B3%A8%E9%87%88&gs_l=psy-ab.3...139272.142786.0.143286.12.11.0.0.0.0.338.1807.0j5j1j2.8.0....0...1c.1j4.64.psy-ab..7.1.175...33i21k1.0._GOIjiPCOTU

詳細PDF入門 ー 実装して学ぼう!PDFファイルの構造とその書き方読み方 - プログラムモグモグ
https://itchyny.hatenablog.com/entry/2015/09/16/100000

PDFファイルのチェック - Qiita
https://qiita.com/7shi/items/f48a93f8e769e2cf5dec

PDFの注釈機能で遊ぶ - hak7a3が書き残す何か
http://hak7a3.hatenablog.com/entry/2017/12/09/210129

PDFの注釈とは,
メモや音,動画といった要素をページに付与する,もしくは
インタラクティブな要素を提供する
機能である.具体的には,次のような要素をPDF文書に付与することができる.

tex

日本語が扱える alpine の LaTeX イメージを作った話 - 3846masa's memo
http://3846masa.hatenablog.jp/entry/2017/02/08/215920

DockerでらくらくLaTeX環境構築 - Qiita
https://qiita.com/Shitimi_613/items/9706d57fb7bc17cbed0e

海外情報

日本からアメリカのGoogle (google.com) で英語で検索する方法 | 海外SEO情報ブログ
https://www.suzukikenichi.com/blog/how-to-search-on-google-com-in-english-from-japan/

What Are Annotations? | Inside PSPDFKit
https://pspdfkit.com/blog/2018/what-are-annotations/

PDF - Wikipedia
https://en.wikipedia.org/wiki/PDF

Interactive elements
PDF files may contain interactive elements such as annotations, form fields, video, 3D and rich media.s

tool

PDF Tools 変換・作成・編集 API|トラスト・ソフトウェア・システム
http://www.pdf-tools.trustss.co.jp/

Tools for Extracting Data and Text from PDFs - A Review - Open Knowledge Labs
http://okfnlabs.org/blog/2016/04/19/pdf-tools-extract-text-and-data-from-pdfs.html

PDFKit (mac)

PDFAnnotation - PDFKit | Apple Developer Documentation
https://developer.apple.com/documentation/pdfkit/pdfannotation

Annotations in PDFKit
https://tabmemfree.appspot.com/blank.html#title=Annotations%20in%20PDFKit

NodeJS

pdfkit.org/demo/browser.html
http://pdfkit.org/demo/browser.html

devongovett/pdfkit: A JavaScript PDF generation library for Node and the browser
https://github.com/devongovett/pdfkit

instructure/pdf-annotate.js: Annotation layer for pdf.js
https://github.com/instructure/pdf-annotate.js/

PDFJSAnnotate - WebベースでPDFに注釈 MOONGIFT
https://www.moongift.jp/2016/11/pdfjsannotate-web%E3%83%99%E3%83%BC%E3%82%B9%E3%81%A7pdf%E3%81%AB%E6%B3%A8%E9%87%88/

Golang

unidoc - GoDoc
https://godoc.org/github.com/unidoc/unidoc

unidoc

unidoc - GoDoc
https://godoc.org/github.com/unidoc/unidoc

annotator - GoDoc
https://godoc.org/github.com/unidoc/unidoc/pdf/annotator

UniDoc - Examples for PDF handling with UniDoc
https://unidoc.io/examples/annotations/list

JetBrains

JetBrains GoLand Plugin Repository
https://plugins.jetbrains.com/go

文字コードの扱いにハマる

utf16BEか、PDFDDocEncodingになるらしい。

PDF/UAという独自規格がありADOBEが特定のバージョンの規格書を公開している。
基本的にはUTF16ベースみたいなのだが、、iconvとかの標準では扱っていないので工夫する必要があるっぽい

この規格は、Latin1に近く、ISO32000-1:2008とか、、いくつかバージョンがありそう。

Go言語 - 日本語文字列の操作 - はけの徒然日記
http://d.hatena.ne.jp/hake/20150826/p1

UTF-8な日本語文字数を考慮したPrintf("%s")指定方法
https://gist.github.com/kyokomi/adfc56e25eb6a9a99b30

utf8 - The Go Programming Language
https://golang.org/pkg/unicode/utf8/

core - GoDoc
https://godoc.org/github.com/unidoc/unidoc/pdf/core#PdfObject

PDFのUnicode utf-8 | CODE Q&A [日本語]
https://code.i-harness.com/ja/q/1f4a2

UTF-8 Comments in Annotation | Adobe Community
https://forums.adobe.com/thread/796290

PDF strings don't use UTF-8. They are either PDDocEncoding (ISO Latin 1) or UTF16BE.
Since you are using the Acrobat SDK, you can use the ASText class to convert for you.

So my observation is that the PDF standard supports either Latin-1 embedded as a set of characters within () braces, or either Latin-1 or UTF16BE embedded as hex values within <> braces. When generating a CosString, you have to explicitly tell it to store the string as hex, or it just ignores the BOM and considers everything to be 8-bit characters.

nkf - コマンド (プログラム) の説明 - Linux コマンド集 一覧表
http://kazmax.zpp.jp/cmd/n/nkf.1.html

go run sandbox/main.go ~/hoge.pdf |nkf -Lu -l |less

第3章のPDFリファレンスでは、これがUnicodeについて言います。

UTF-8 Comments in Annotation | Adobe Community
https://forums.adobe.com/thread/796290

テキスト文字列は、PDFDocEncodingまたはUnicode文字エンコードのいずれかでエンコードされます。 PDFDocEncodingは、ISO Latin 1エンコーディングのスーパーセットであり、付録Dに記載されています。Unicodeについては、Unicode ConsortiumのUnicode標準で説明しています(参考文献を参照)。 Unicodeでエンコードされたテキスト文字列の場合、最初の2バイトは254に続いて255でなければなりません。これらの2バイトはUnicodeバイトオーダーマーカーU + FEFFを表し、文字列がUTF-16BE(ビッグエンディアン) Unicode標準で指定されています。 (このメカニズムは、単語やフレーズの意味のある始まりではないと思われるydieresisという2つの文字でPDFDocEncodingを使用して文字列を開始することを排除します)。

GO言語で文字コードを扱うライブラリの使用例 - Qiita
https://qiita.com/irugo/items/390bd187871c7716a1e1

djimenez/iconv-go: iconv support for Go
https://github.com/djimenez/iconv-go

iconv-go latin1 - Google 検索
https://www.google.co.jp/search?q=iconv-go+latin1&oq=iconv-go+latin1&aqs=chrome..69i57.2186j0j7&sourceid=chrome&ie=UTF-8

ディレクトリ内ファイルの一括 latin1→ UTF8 文字コード変換 - Qiita
https://qiita.com/AsladaGSX/items/6921e0fbbc5ab797e13c

iconvコマンドで使えるエンコード名 - はてブロ@ama_ch
http://ama-ch.hatenablog.com/entry/20081204/1228371690

ISO 32000-1 golang - Google 検索
https://www.google.co.jp/search?num=100&ei=Y5YCW_iGN6Ln0gLxsbqACQ&q=ISO+32000-1+golang&oq=ISO+32000-1+golang&gs_l=psy-ab.3...187780.188630.0.188900.6.6.0.0.0.0.151.419.0j3.3.0....0...1c.1.64.psy-ab..3.0.0....0.7mr_15HoAFQ

プログラムモグモグ
https://itchyny.hatenablog.com/?page=1446130800

PDF/UA-1(ISO 14289-1)について | アンテナハウス PDF資料室
http://www.antenna.co.jp/pdf/reference/PDFUA-1.html

ISO 32000に準拠するPDFってどんなもの? | アンテナハウス PDF資料室
http://www.antenna.co.jp/pdf/reference/iso32000-conformance.html

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
3