-
Notifications
You must be signed in to change notification settings - Fork 4
/
658.txt
229 lines (156 loc) · 9.77 KB
/
658.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
[3] [DFN[[RUBY[[[PDF]]][ぴーでぃーえふ]]]] は、 [[Adobe]] の開発した[[文書形式]]です。
* 構文
[FIG(short list)[ [24] [[PDF]]
- [[大エンディアン]]
- [[PDFの言語エスケープシーケンス]]
- [[PDF座標系]]
- [[PDFの日時形式]]
- [[Base85]]
- [[base16]]
- [[UTF-16BE]]
- [[OpenType]]
- [[JPEG]]
- [[JPEG2000]]
- [[XFA]]
- [[PDF写像資源]]
]FIG]
* MIME型
[5] [[PDF]] の [[MIME型]]は [CODE(MIME)@en[[[application/pdf]]]] です。
* 素片識別子
[12] ページ指定などが[[素片識別子]]により行えます。
;; [[素片識別子]]参照。
* Web における PDF
[8] [[PDF]] は、[[文書]]の配布手段として [[Web]] 上でもよく用いられています。
[9] 多くは、[[ダウンロード]]により、または[[閲覧文脈]]内での表示を想定して配布されています。
かつては [CODE(HTMLe)@en[[[embed]]]] や [CODE(HTMLe)@en[[[object]]]]
により[[プラグイン]]を埋め込んで表示する方法もよく採られていましたが、
最近ではあまり見かけません。
[10] 現在の多くの [[Webブラウザー]]は、 [[PDF]] の表示機能を内蔵しています。
([[PDF]] の全機能を実装しているとは限りません。) [[Webサイト]]によっては、
[[HTML]] で指定した [[PDF]] を[[フレーム]]内に表示させることがあります。
何らかの形での [[PDF]] への対応は [[Web互換]]のために必要です。
[EG[
[13] 例えば [[DRM]] を使った [[PDF]] は、[[Webブラウザー]]内に表示できません。
そのような [[PDF]] は、[[相互運用性]]に問題がありますから、 [[Web]]
では使うべきではありません。
]EG]
[11] [[PDF]] には[[ハイパーリンク]]機能があり、 [[PDF]] から [[Web]]
へ[[リンク]]することができます。
;; 参考文献を示す程度の利用に留まっており、
[[PDF]] と [[Web]] を相互に行き来する形の利用はほとんどされていません。
[20] いくつかの[[Webブラウザー]]は、[[物理形を得る]]方法の1出力先として
[[PDF]] を提供しています。
[EG[
[21] [[Chrome]] は[[印刷]]機能から [[PDF]] として保存することを選べます。
]EG]
[26] [CITE@en-US[Adobe and Microsoft Bring Industry-Leading Acrobat PDF Experience to 1.4 Billion Windows Users through Microsoft Edge - Microsoft Edge Blog]], [[Microsoft Edge Blog]], [TIME[2023-02-11T00:07:45.000Z]] <https://blogs.windows.com/msedgedev/2023/02/08/adobe-acrobat-microsoft-edge-pdf/>
[27] [CITE@en[Microsoft Edge and Adobe partner to improve the PDF experience]], [TIME[2023-02-11T00:08:28.000Z]] <https://techcommunity.microsoft.com/t5/microsoft-edge-insider/microsoft-edge-and-adobe-partner-to-improve-the-pdf-experience/ba-p/3733481>
[28]
どうして [[Chrome]] は [[HTML]] に使える [[Google翻訳]]を [[PDF]] では使わせてくれないのかねえ。
[29]
[[Firefox]] は [[PDF]] を [CODE[pdf.js]] で表示していて [[DOM木]]にしているのに、
それを [[HTML]] として保存する機能を提供してくれないのも地味に不便。
[[DOM木]]なんだからそれを保存してやろうかと思ったら、
表示中のページの前後しか [[DOM]] には入ってなかった。
ページを進めていくと挿入されていくけど、前の方のページが消されていくので、
同時に全部 [[DOM]] にある状態にならない。
[CODE[pdf.js]] を直接使えばどうにかできるのだろうけど、
せっかくなんだから[[ブラウザー]]標準でどうにかしてほしい。
[30]
[[Chrome]] も内部的には同じように[[レンダリング]]していると思うのだけど
[[Chrome]] では [[DOM木]]が隠されてて [[JavaScript]]
アクセスできないのなんでだろう。
* 活用
[33] Q: [[PDF]] からテキストデータを取り出したい。
[34] A:
[PRE(code)[
$ pdftotext [VAR[input.pdf]] [VAR[output.txt]]
]PRE]
[35] Q: テキストがよくわからない順序に変わってしまいます。
[36] A: 元の順序を保持するオプションがあります。
[PRE(code)[
$ pdftotext -raw [VAR[input.pdf]] [VAR[output.txt]]
]PRE]
[37]
Q: テキストに座標もつけてほしい。
[38] A:
[PRE(code)[
$ pdftohtml -xml [VAR[input.pdf]] [VAR[output.txt]]
]PRE]
独自形式 [[XML]]。定形なので行指向テキストファイルとしても処理できます。
[39]
Q: [[PDF]] から画像データを取り出したい。
[40]
A: >>38 で同じディレクトリーに画像ファイルが作成されます。
* 関連
[4] [[PostScript]] と [[PDF]] は深い関連があります。[[PDF]] はおおよそ [[PostScript]]
の[[部分集合]]的なものとなっています。
* メモ
[2]
[[PDF]] と [[RDF]] は紛らわしい。
([[名無しさん]] [WEAK[2006-12-23 16:50:02 +00:00]])
[1] ''KOBU - PDF by Hand'' <http://www.kobu.com/docs/pdf/pdfxhand.htm>
[FIG(quote)[
[FIGCAPTION[
[6] [CITE@en[RFC 6170 - Internet X.509 Public Key Infrastructure -- Certificate Image]]
([TIME[2015-02-01 21:57:35 +09:00]] 版)
<https://tools.ietf.org/html/rfc6170#section-5.1>
]FIGCAPTION]
> A certificate image MAY be provided in the form of a Portable
> Document Format (PDF) document according to '''['''ISO32000''']''' and following
> the conventions defined in this section. When a certificate image is
> formatted as a PDF document, it MUST also be formatted according to
> the profile PDF/A '''['''ISO19005''']'''.
]FIG]
[7] [CITE@en[Add support for "page=" and "search=" URL parameters · Issue #1875 · mozilla/pdf.js]]
([TIME[2015-06-25 15:52:21 +09:00]] 版)
<https://github.com/mozilla/pdf.js/issues/1875>
[14] [CITE[Issue 523425 - chromium - failed to load GB 18030-2005 PDF - An open-source project to help move the web forward. - Google Project Hosting]]
([TIME[2015-08-22 11:54:56 +09:00]] 版)
<https://code.google.com/p/chromium/issues/detail?id=523425>
[15] [CITE@ja[詳細PDF入門 ー 実装して学ぼう!PDFファイルの構造とその書き方読み方 - プログラムモグモグ]]
([TIME[2015-09-16 21:18:40 +09:00]] 版)
<http://itchyny.hatenablog.com/entry/2015/09/16/100000>
[16] [CITE[パスポート更新申請のPDFの仕様が酷いと聞いたので確認してみた - Windows 2000 Blog]]
( ([TIME[2016-06-10 12:05:41 +09:00]]))
<http://blog.livedoor.jp/blackwingcat/archives/1930035.html>
[FIG(quote)[
[FIGCAPTION[
[17] [CITE@ja[IE11とFirefoxのAdobe PDFで意図しない情報漏洩の可能性 | スラド セキュリティ]]
([TIME[2016-11-17 16:32:07 +09:00]])
<https://security.srad.jp/story/16/11/16/147247/>
]FIGCAPTION]
> 問題の脆弱性は、PDFにプログラムを埋め込める「FormCalc」という機能に関連するもの。FormCalcにはネットワーク経由でコンテンツの取得や送信を行える「Get」や「Post」、「Put」といった命令が用意されている。これを利用してPDFが配信されているドメインと同じドメイン上のデータを取得し、それを外部サーバーに送信するという処理をPDFを閲覧するマシン上で自動実行させることができるという。
> 一般的なWebブラウザでは、スクリプトによるHTTPリクエストについて、リクエスト先をそのスクリプトを配信するドメインに限定する、「同一オリジンポリシー(same-origin policy)」が適用されている(Mozillaによるドキュメント)。しかし、FormCalcではこの制限が緩く、取得した情報を別のサイトに送信できてしまうという。
]FIG]
[18] [CITE@en-US[Edge displays "123456" in PDF but prints "114447" - Microsoft Edge Development]]
([TIME[2017-05-08 11:38:35 +09:00]])
<https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/11896203/>
[19] [CODE[pdf_as]] 色々使えて便利。
[FIG(quote)[
[FIGCAPTION[
[22] [CITE@ja[【重要】PDF調査票回答の推奨環境変更のお知らせ | 政府統計オンライン調査総合窓口]]
([TIME[2018-10-29 22:48:46 +09:00]])
<https://www.e-survey.go.jp/survey_Infomation/907>
]FIGCAPTION]
> 平成30年10月10日より、PDF調査票回答の推奨環境が一部変更となりました。
> PDF 調査票に回答いただく際は「Internet Explorer11」をご使用いただくようお願いいたします。
> (※「Firefox ESR」、「Safari」で回答送信ができない状況となりました)
]FIG]
[23] [CITE[画像データからのテキスト抽出 技術について]]
([TIME[2011-09-16 14:33:54 +09:00]])
<https://aebs.or.jp/pdf/20110803_txtt.pdf>
[25] [CITE@ja[PDF フォーマット]], [TIME[2020-12-28T06:26:04.000Z]] <https://aznote.jakou.com/prog/pdf/index.html>
[31]
[CODE[pdf.js]] のようなものの他にも[[ウェブ]]上でさがすと無料で [[PDF]] から
[[HTML]] に変換できるサービスがいくつかあります。
試しにいくつか使ってみましたけど、まともに動かないもの (変換エラーになるもの)
がいくつか、変換結果から文字が抜けまくっているもの ([[非ASCII文字]]を扱えない?)
など酷いものが多い。ちゃんと動いたものもあるけど、どんな [[PDF]] でも大丈夫なのかたまたまテストに使ったものだけちゃんと動くのかわからない。
(ちゃんと動くものに限って無料枠が少なかったり。)
[32] そういうサイト、どうせバックエンドは同じ [[OSS]] なんじゃ?と思ってたけど案外そうでもないのね。
[FIG(data)[ [82] [[文字関係]]
:key: [DFN[[CODE[pdf:char]]]]
:desc:
[[PDF]] の文字データ。
]FIG]