ã¯ããã«
ãPHPã§PDFãä½æããå ´åã«ã¯PDFLibãmPDFãFDPDFãªã©ãã¾ãã¾ãªé¸æè¢ãããã¾ãããã©ã¤ã»ã³ã¹ãããã©ã¼ãã³ã¹ãªã©ã®ç¹ã§åé¡ãããå ´åã«ãHaruã®å©ç¨ãæ¤è¨ãã¦ã¿ã¦ã¯ãããã§ããããã
ãHaruã¯ZLibãPNGã¨åæ§ã«ãé常ã«ç·©ãã©ã¤ã»ã³ã¹å½¢æ ãåã£ã¦ããããããµã¼ãã¹ã®ç¨®é¡ãåããçµã¿è¾¼ã¿ãããç¹ã«ç¹å¾´ãããã¾ãã
ãã¾ããPHPã®ãã¤ãã£ãã¨ã¯ã¹ãã³ã·ã§ã³ã¨ãã¦æä¾ããã¦ãããããPHPã®ã©ã¤ãã©ãªã¨ãã¦ããã©ã¼ãã³ã¹ãåºãªãå ´åã«ãå©ç¹ãããã¾ãã
ãã¨ã¯ããããµã¤ãä¸ã«ããã¾ãæ å ±ããªããæ¥æ¬èªã®å©ç¨ã«é¢ãã¦ä¸å®ãããããããã¾ããããããæåã«ããã¤ãæããã©ã¤ãã©ãªã¯ãå ã ã¯æµ·å¤çºä¿¡ã®ã©ã¤ãã©ãªã§ããã対ãã¦ãHaruã¯libharuã¨ããCã®ã©ã¤ãã©ãªã®ã¨ã¯ã¹ãã³ã·ã§ã³ã§ãããlibharuã¯æ¥æ¬ãçºä¿¡å ã¨ãªã£ã¦ãã¾ãã®ã§ãæ¥æ¬èªã«é¢ãã¦ãå®å¿ãã¦å©ç¨ã§ãã¾ãï¼ç¾å¨ã®ã¡ã³ããã³ã¹ã¯æ¥æ¬äººã§ã¯ãªããªã£ã¦ãã¾ãï¼ã
対象èªè
ãPHPã§ã®åºæ¬æ§æãç解ãã¦ããæ¹ã§ã帳票å°å·ãPDFãã¡ã¤ã«ã«èå³ãããæ¹ã対象ã¨ãã¦ãã¾ãã
å¿ è¦ãªç°å¢
ããã®è¨äºã§ã¯ã以ä¸ã®ã©ã¤ãã©ãªã使ç¨ãã¦ãã¾ãã
- libharu 2.1
- haru 1.0.4
ãã¾ããPHP5.4ã使ç¨ããLinuxã§åä½ã確èªãã¦ãã¾ãã
Haruã®ã¤ã³ã¹ãã¼ã«
ãlibharuã¯ã以ä¸ã®ããããã®æ¹æ³ã§ã¤ã³ã¹ãã¼ã«ã§ãã¾ãã
# yum install libharu
# wget http://libharu.org/files/libharu-2.1.0.tar.gz # tar xvfz libharu-2.1.0.tar.gz # cd libharu-2.1.0 # ./configure; make; make install
ãPHPã®Haruã¯ãlibharu2.2以ä¸ã§ã®å©ç¨ã¯ã§ãã¾ãããå¿ ã2.1ãã¤ã³ã¹ãã¼ã«ãã¦ãã ããã
ãã¾ããPHPã®ã¨ã¯ã¹ãã³ã·ã§ã³ã¯ä»¥ä¸ã®ããã«ã¤ã³ã¹ãã¼ã«ã§ãã¾ãã
# pecl install haru
PDFã®æ³¨æç¹
ãHaruã®APIã¯ãä»ã®ã©ã¤ãã©ãªã«æ¯ã¹ãPDFå é¨ä»æ§ã«è¿ãAPIã§ããå¾ã£ã¦ãHaruã使ãããã«ã¯ãæä½éã®PDFã®ä»æ§ã«ã¤ãã¦ãç¥ã£ã¦ããã¨ä¾¿å©ã§ããç¹ã«æ³¨æããç¹ã¨ãã¦ãPDFã®åº§æ¨è»¸ãããã¾ãã
ãPDFã§ã¯é常ã人ãæèããå·¦ä¸ãï¼0,0ï¼ã§å³ä¸ã«åãã£ã¦åº§æ¨ãåºããã®ã§ã¯ãªããå·¦ä¸ãï¼0,0ï¼ã«ãªã£ã¦ãããå³ä¸ã«åãã£ã¦åº§æ¨ãåºãã£ã¦ãã¾ããå°ã åããã¥ããã®ã§ãä¸å³ãã¿ãã¨åããããããªãã¾ãã
ãY軸ã¯0ã«åãã£ã¦è¨è¿°ãã¦ããããã«ãªãã®ã§ã注æãã¦ãã ããã
ãã¾ãããµã¤ãºãå¤å°è¨ç®ãé¢åã«ãªã£ã¦ãã¾ããä¾ãã°ãA4ã®æ¨ªãµã¤ãºã¯595.27600097656ã¨ãªã£ã¦ãããã¤ã³ãã®æ¦å¿µã§è¨ç®ããã¦ãã¾ããå¾ã£ã¦ããªã§è¨ç®ããéã«ã¯ãï¼mmï¼×72÷25.4ããªã©ã使ã£ã¦ãè¿ä¼¼å¤ãæ±ããå¿ è¦ãããã¾ãã