PDFãè¦ãã¦ã¿ãã(å ¥éç·¨)
ãã®è¨äºã¯ãImaizumi Lab Advent Calendar 8æ¥ç®ã§ãã
ãã¯ãä»æ¥ãä½æ¥ãªã®ãããããªããªã£ã¦ãã¾ããã
ã¯ããã«
é¨ãããã¨æã£ã¦ãã好ããªããã¹ãã¨ãã£ã¿(vimã¨ãemacsã¨ã...)ã§PDFãéãã¦ã¿ã¦ãã ããã ãã£ã¨ãã®ãããªã³ã¼ãã表示ãããã¯ãã§ãã
ã¨ããã©ããã§ãããPDFãLengthãFilterãªã©ã¨ãã£ã人éã«ç解ã§ããåèªãåºã¦ãã¦ãã¾ããã
æå¤ã¨PDFã£ã¦èªãããã ã¨æãã¾ãããï¼ æ§é ã«ã¤ãã¦è©³ãããªãã°åºã¦ããæååãã©ãããæå³ãªã®ããããããã«ãªãããã§ãã
å®ã¯PDFã®æ§é ã®ä»æ§ã¯å ¬éããã¦ãããç¡æã§èªããã¨ãã§ãã¾ãã
- PDFãªãã¡ã¬ã³ã¹
https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdf_reference_archive/pdf_reference_1-7.pdf
PDFã®æ¦ç¥ãã¤ããã®ã«è¯ãã§ããã大å¤ãªãã¨ã«1310ãã¼ã¸ãããã¾ãã
PDFã®æ§é ã«èå³ãæã£ã¦ãããããã«ãããå ¨é¨èªãã®ã¯å³ããã§ãããã
ã¨ããããã§æ¬ç¨¿ã§ã¯åãã¦PDFã®æ§é ã«è§¦ãã人ã対象ã¨ããPDFãªãã¡ã¬ã³ã¹ã®ç¬¬ä¸ç« (Syntax)ãä¸å¿ã«ãPDFã®ç°¡åãªä»æ§ã«ã¤ãã¦è¦ã¦ããããã¨æãã¾ãã*1
ä¸ããé çªã«è¦ãã¦ã¿ã
PDFã®æ§é ã¯ä¸ãã以ä¸ã®ããã«ãªã£ã¦ãã¾ããæ¯éçããããæå ã«ãã¡ã¤ã«ãç¨æãã¦è¦ãã¦ã¿ã¦ãã ããã
(注æï¼PDFã¯ãªãã¹ãä¸èº«ãã·ã³ãã«ãªãã®(æç« ãHello, worldã ãã¨ã)ãç¨æããæ¹ãããã¨æãã¾ããä½åãæ´æ°ãã¦ãããã¡ã¤ã«ã ã¨è¿½å æ´æ°ã¨ããä»çµã¿ã®ããã§ãç¹å®ã®æ§é ãè¤æ°ååºã¦ãããããããæ¬ç¨¿ã®èª¬æã¨åããªããªãã¾ãã追å æ´æ°ã«ã¤ãã¦ã¯æ¬ç¨¿ã§ã¯æ±ãã¾ãã)
ããã
PDFã®ä¸çªå é ã«ããã¾ããã%PDF-(æ°å)ãã¨ãªã£ã¦ããé¨åããããã§ããæ°åé¨åã¯PDFã®ãã¼ã¸ã§ã³ã表ãã¦ãã¾ãã
ããã£
ã¤ã³ãã¤ã¬ã¯ããªãã¸ã§ã¯ã(ååä»ããªãã¸ã§ã¯ã)ã¨å¼ã°ãããã®ãä¸ããé çªã«ä¸¦ãã§ãã¾ãã
ã¤ã³ãã¤ã¬ã¯ããªãã¸ã§ã¯ãã®èª¬æãããåã«ãã¾ããªãã¸ã§ã¯ãã«ã¤ãã¦èª¬æãã¾ãããªãã¸ã§ã¯ãã¨ã¯PDFãæ§æããè¦ç´ ã§ã
- Boolean
- Number
- String
- Name
- Array
- Dictionary
- Stream
- The null object
ã®8種é¡ãåå¨ãã¾ãã
ã¨ãã£ã¿ã§PDFãéããæã«è¡¨ç¤ºããã¦ãããã®ã¯ããªãã¸ã§ã¯ãã®éåä½ã§ãã
ãããªãã¸ã§ã¯ãã®ä¸ã«ã¯å¥ã®ãªãã¸ã§ã¯ããå«ããã¨ãã§ãã¾ããArrayã¨Numberã®ä¾ã ã¨ããããããã§ããã
ãã¦ãæ¬é¡ã«æ»ãã¾ããã¤ã³ãã¤ã¬ã¯ããªãã¸ã§ã¯ãã¨ã¯ãä»ã®ãªãã¸ã§ã¯ãããåç §ãããããã«ã©ãã«ä»ãããããªãã¸ã§ã¯ãã®ãã¨ã§ãã
ç»åã§èª¬æããã¨ã6 0 obj ~ endobj ã¾ã§ãã¤ã³ãã¤ã¬ã¯ããªãã¸ã§ã¯ãã§ãã
ã¤ã³ãã¤ã¬ã¯ããªãã¸ã§ã¯ãã¯ã©ãã«ã¨ãã¦ãªãã¸ã§ã¯ãçªå·ã¨ä¸ä»£çªå·ãæã¡ã¾ãããã®äºã¤ã«ãããã¤ã³ãã¤ã¬ã¯ããªãã¸ã§ã¯ããç¹å®ãããã¨ãã§ãã¾ãã
ä¸è¨ã®ç»åã ã¨ã6ããªãã¸ã§ã¯ãçªå·ã§0ãä¸ä»£çªå·ã§ãããªãã¸ã§ã¯ãçªå·ã¯ãªãã¸ã§ã¯ãã表ãçªå·ã§ããä¸ä»£çªå·ã¯ãªãã¸ã§ã¯ããæ´æ°ãããéã«å¤æ´ãããå¯è½æ§ãããçªå·ã§ãã
ã¨ããã§ãç»åä¸ã«ã7 0 Rãã8 0 Rãã¨ãã£ãæååãããã¾ãããããã¯ããã®ãªãã¸ã§ã¯ãã7 0 objã¨8 0 objãåç §ãã¦ãããã¨ãæãã¦ãã¾ãã
ã¯ãã¹ãªãã¡ã¬ã³ã¹ãã¼ãã«
PDFããã¥ã¼ã¯ã§è¦ã¦ããã¨ãããã¼ã¸ã®éä¸ããã§ãç¬æã«èªã¿è¾¼ã¾ãã¾ãããï¼ ãããå®ç¾ãã¦ããã®ããã®ã¯ãã¹ãªãã¡ã¬ã³ã¹ãã¼ãã«ã§ãã
ç»åä¸ã®ã0 21ã¯ãªãã¸ã§ã¯ãçªå·0-20ã¾ã§ã®æ å ±ãå ¥ã£ã¦ãããã¨ã示ãã¦ãã¾ãã(ãªãã¸ã§ã¯ãçªå·ã0ã®ã¤ã³ãã¤ã¬ã¯ããªãã¸ã§ã¯ããªãã¦ãªããããªããã¨è¨ããããã§ãããããã¯ç¹æ®ãªã¤ã³ãã¤ã¬ã¯ããªãã¸ã§ã¯ãã®ãã¨ã§ã常ã«ä½¿ããã¾ãã)
ãã®ä¸ã®ãxxxxxxxxxx yyyyy nãã¨ãªã£ã¦ãããã®ã¯ãã¤ã³ãã¤ã¬ã¯ããªãã¸ã§ã¯ãããã¡ã¤ã«ã®å é ããã©ã®ä½ç½®ã«ãããã示ãã¦ãã¾ããç»åã®å ´åã ã¨ãä¸ããé çªã«ãªãã¸ã§ã¯ãçªå·0ããã®æ å ±ãå ¥ã£ã¦ãã¾ãã
xxxxxxxxxxãå é ããã®ãªãã»ãããyyyyyãä¸ä»£çªå·ãæå¾ã®nã¯ä½¿ç¨ä¸ã®ã¤ã³ãã¤ã¬ã¯ããªãã¸ã§ã¯ãã§ãããã¨ãæãã¾ãã(æå¾ã®nãfã«ãªãã¨æªä½¿ç¨ã§ãããã¨ãæãã¾ã)
ãã¬ã¤ã©ã¼
ã¯ãã¹ãªãã¡ã¬ã³ã¹ãã¼ãã«ã¨ç¹æ®ãªãªãã¸ã§ã¯ããç´ æ©ãèªã¿è¾¼ãããã®ãã®ã§ãã
ä¸ããé çªã«trailer(ãã¼ã¯ã¼ã)ããã¬ã¤ã©ã¼ãã£ã¯ã·ã§ããªãstartxref(ãã¼ã¯ã¼ã)ãxref(ãã¼ã¯ã¼ã)ã®å é ã¾ã§ã®ãªãã»ããã%%EOFã¨ãªã£ã¦ãã¾ãã
ãããã«
PDFãã¨ãã£ã¿ã§è¦ãã¦ã¿ãã¨ãæå¤ã¨äººéã«ãç解ã§ããæ§é ããã¦ãããã¨ãåãã£ãã®ã§ã¯ãªãã§ããããã
PDFã«é¢ãã¦ã¯ãã¿ãã¾ã ããã¤ãããã®ã§ã追ã ç´¹ä»ãã¦ãããã¨æã£ã¦ãã¾ãã次åã¯(å¤å)PDFã®è§£æãã¼ã«ç·¨ã§ãã
åèæç®
PDFの仕様書を読む 第24回 3.4.5 Incremental Updates : log log log
https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdf_reference_archive/pdf_reference_1-7.pdf
*1:PDFã®ææ°ã®è¦æ ¼ã¯PDF2.0ã§ããããªãã¡ã¬ã³ã¹ãPDF1.7ã¾ã§ã®ãã®ãªã®ã§1.7ã¾ã§ã®ä»æ§ã§è§£èª¬ãã¾ããããã§æ¸ãã¦ãããã¨ã¯å¤æ´ã¯ãªãã¯ãã§ã