{"id":878,"date":"2024-04-15T13:17:21","date_gmt":"2024-04-15T04:17:21","guid":{"rendered":"http:\/\/inwelly.com\/?p=878"},"modified":"2024-04-23T04:31:57","modified_gmt":"2024-04-22T19:31:57","slug":"php-dompdf-%ec%84%a4%ec%b9%98%eb%b0%a9%eb%b2%95-on-apm-%eb%a6%ac%eb%88%85%ec%8a%a4-%ec%84%9c%eb%b2%84","status":"publish","type":"post","link":"https:\/\/inwelly.com\/?p=878","title":{"rendered":"PHP DOMPDF \uc124\uce58\ubc29\ubc95 on APM , \ub9ac\ub205\uc2a4 \uc11c\ubc84"},"content":{"rendered":"\n<p>DOMPDF ( WEB \ud398\uc774\uc9c0 -> PDF \ud30c\uc77c ) \ud504\ub85c\uadf8\ub7a8 \ucd94\uac00 for PHP<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\ud574\ub2f9 \ud504\ub85c\uadf8\ub7a8 \uc774\uc804\uc5d0 TCPDF , FPDF \ub97c \uc11c\ubc84\uc5d0 \uc124\uce58\ud574\uc11c \ud55c\uae00 \uacfc \uc774\ubbf8\uc9c0 \uc6f9\ud398\uc774\uc9c0\ub97c\nPDF \ub85c \ub9cc\ub4e4\uc5b4 \ubd24\uc9c0\ub9cc \ub450\uac00\uc9c0\ubaa8\ub450 \ucd5c\uadfc\uc758 CSS \uac00 \uc801\uc6a9\ub41c \ud398\uc774\uc9c0\ub97c\n\uae68\ub057\ud558\uac8c PDF \ud30c\uc77c\ub85c \ub9cc\ub4e4\uc9c0 \ubabb\ud558\ub294\uac83\uc744 \ud655\uc778\ud558\uc600\ub2e4.\n\uc774\uc5d0 \uc774\ub9ac\uc800\ub9ac \ucc3e\ub2e4 dompdf \ub97c \ubc1c\uacac\ud558\uc5ec \uc11c\ubc84\uc5d0 \uc801\uc6a9 \ud574\ubcf4\ub2c8 \ub9e4\uc6b0 web page \uc5d0 \n\ud45c\uc2dc \ub418\ub294 \ub9cc\ud07c\uc740 PDF \uac00 \ub9cc\ub4e4\uc5b4 \uc9c0\ub294\uac83\uc744 \uc54c\uac8c \ub418\uc5b4 \uac1c\ubc1c\uc2dc \uc801\uc6a9\ud55c \uacbd\ud5d8\uc744\n\uc544\ub798\uc640 \uac19\uc774 \ub0a8\uae34\ub2e4. ( \uc0ac\uc124\uc774 \uae38\uad70 \u314b )\n\n1. \ub2e4\uc6b4\ub85c\ub4dc\nhttps:&#47;&#47;github.com\/dompdf\/dompdf\/releases  \n\ud574\ub2f9 \ud398\uc774\uc9c0\uc5d0\uc11c \ubc84\uc83c\uc744 0.6.2 \ub97c \uc120\ud0dd\ud574\uc11c \ub2e4\uc6b4\ub85c\ub4dc ( \ud55c\uae00 \uc9c0\uc6d0\uc774 \uc6d0\ud65c\ud55c \ubc84\uc83c\uc774\ub77c\uace0 \ud568 )\n( https:\/\/github.com\/dompdf\/dompdf\/releases\/download\/v0.6.2\/dompdf-0.6.2.zip ) \n\n2. \ud574\ub2f9 \ud504\ub85c\uadf8\ub7a8 \uc124\uce58\uc804 PHP \uc5d0 \uc544\ub798\uc758 extension \uc124\uce58 \ub418\uc5b4 \uc788\ub294\uc9c0 \ud655\uc778 \ud574\ubcf8\ub2e4.\nMBString extension\nGD extension\nDOM extension\n( \ud655\uc778\ubc29\ubc95 phpinfo();  \uc774\uc6a9 ) \n\n3. \ub2e4\uc6b4\ubc1b\uc740 dompdf \uc11c\ubc84\uc5d0 \uc801\ub2f9\ud55c \uc704\uce58\uc5d0 \uc555\ucd95\uc744 \ud47c\ub2e4.\n\n4. dompdf\/lib \ud3f4\ub354\uc548\uc5d0  \ud544\uc694\ud55c \ud504\ub85c\uadf8\ub7a8 php-font-lib \uad00\ub828\uc774 \uc5c6\uc73c\ubbc0\ub85c \nhttps:\/\/github.com\/PhenX\/php-font-lib\/releases   \ud574\ub2f9 \uacbd\ub85c\uc5d0\uc11c 0.2.2\ubc84\uc804\uc744 \ub2e4\uc6b4\ub85c\ub4dc \ud574\uc11c \n\uc555\ucd95\uc744 \ud480\uace0 dompdf\/lib  \uc548\uc5d0 \ub123\uc5b4 \uc900\ub2e4.\n\n5. dompdf \ud3f4\ub354\uc5d0 \uc6d0\ud558\ub294 \uc774\ub984\uc758 \ud30c\uc77c\uba85\uc744( \uc608: example.php ) \ub9cc\ub4e4\uace0 \uc544\ub798\uc758 \uc18c\uc2a4\uac00 \uc2e4\ud589\ub418\ub294\uc9c0 \ube0c\ub77c\uc6b0\uc838\uc5d0\uc11c \ud655\uc778\ud55c\ub2e4. \n&lt;?php\ninclude_once('dompdf\/dompdf_config.inc.php');\n$error_level = error_reporting();\nerror_reporting(E_ALL &amp; ~E_NOTICE &amp; ~E_WARNING);\n$name = \"by hongtting \";    \/\/ \ubcc0\uc218 \uc9c0\uc815\uac00\ub2a5\n$html = \"&lt;!DOCTYPE html>\n&lt;html>\n&lt;head>\n&lt;meta http-\uff45quiv='Content-Type' content='text\/html; charset=utf-8'\/>\n&lt;style>\nbody { font-family:'NanumGothic', '\ub098\ub214\uace0\ub515', 'dotum', '\ub3cb\uc6c0'; font-size: 11px; max-width: 750px !important;}\n&lt;\/style>\n&lt;\/head>\n&lt;body>\n&lt;div id='pdf_content_wrap'>\nPDF \ubcc0\ud658 \ud14c\uc2a4\ud2b8 \uc785\ub2c8\ub2e4. $name\n&lt;\/div>\n&lt;\/body>\n&lt;\/html>\";\n\n\/\/dompdf \ubc84\uc804 \ubb38\uc81c\ub85c \uc778\ud55c html \uc18c\uc2a4 \uacf5\ubc31 \uc81c\uac70\n$html = preg_replace('\/\\r\\n|\\r|\\n\/','',$html);\n\/\/html \ucf54\ub4dc\ub97c pdf\ub85c \ubcc0\ud658 (\ubcc0\uacbd\ud558\uba74 \uc548\ub428)\n$dompdf = new \\DOMPDF();\n$dompdf->load_html($html);\n$dompdf->set_paper(\"a4\");    \/\/ A4 \uc6a9\uc9c0\uc5d0 \ub9de\uac8c \uc791\uc131\ub428.\n$dompdf->render();\n$dompdf->stream(\"tempfile.pdf\");  \/\/ \ubc14\ub85c \ub2e4\uc6b4\ub85c\ub4dc \ub428\n\/\/  $dompdf->stream($filename . \".pdf\", array(\"Attachment\" => 0));        \/\/ \ube0c\ub77c\uc6b0\uc838\uc5d0\uc11c \uc5f4\ub9ac\uac8c \ub428.\nerror_reporting($error_level);\n?>\n\n6. PDF \uac00 \ub9cc\ub4e4\uc5b4 \uc9c4\uac83\uc744 \ud655\uc778 \ud560\uc218 \uc788\uc9c0\ub9cc \ud55c\uae00\uc774 \uae68\uc838 \uc788\uc744\uac83\uc774\ub2e4. \n\uc704 \uc18c\uc2a4\uc640 \uac19\uc774 \ud55c\uae00 NanumGothic \ud3f0\ud2b8\uac00 \ud574\ub2f9 \ud504\ub85c\uadf8\ub7a8\uc5d0 \uc124\uce58 \ub418\uc9c0 \uc54a\uc544\uc11c \uae68\uc9c0\ub294\uac83\uc774\ub2c8 \uc778\ud130\ub137\uc5d0\uc11c\n\ud574\ub2f9 Font \ub97c \ucc3e\uc544 \ub2e4\uc6b4 \ubc1b\uc544 dompdf \ud3f4\ub354\uc548\uc5d0 \uc788\ub294 \ud30c\uc77c \uba85 load_font.php \uc744 \uc774\uc6a9\ud574\uc11c \uc544\ub798\uc640 \uac19\uc774 \uc11c\ubc84\uc758 shell \uc5d0\uc11c \uc2e4\ud589\ud55c\ub2e4. \n6-1.\ub2e4\uc6b4\ub85c\ub4dc \ud55c\uae00 ttf \ud30c\uc77c : NanumGothic.ttf\n6-2.load_font.php \ud30c\uc77c\uc758 chmod 777 \ubcc0\uacbd \ud6c4 \uc2e4\ud589\n\n#> .\/load_font.php 'NanumGothic' .\/NanumGothic.ttf .\/NanumGothic.ttf\n\n7. \ube0c\ub77c\uc6b0\uc838\uc5d0\uc11c example.php  \uc2e4\ud589 \ud558\uba74 \uc815\uc0c1\uc801\uc73c\ub85c \ub098\uc624\ub294\uac83\uc744 \ud655\uc778 \ud560 \uc218 \uc788\ub2e4. \n\n\n\n## \uc6b0\ubd84\ud22c\uc5d0 php extention \uc124\uce58\uc9c0 \uc544\ub798 \ucc38\uc870 \nservice apache2 restart\n \nsudo apt-get install php7.0-mbstring\nsudo apt-get install libapache2-mod-php7.0\n \nsudo apt-get install php7.0-gd<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>DOMPDF ( WEB \ud398\uc774\uc9c0 -> PDF \ud30c\uc77c ) \ud504\ub85c\uadf8\ub7a8 \ucd94\uac00 for PHP<\/p>\n","protected":false},"author":1,"featured_media":1251,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-878","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts\/878","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=878"}],"version-history":[{"count":1,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts\/878\/revisions"}],"predecessor-version":[{"id":879,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts\/878\/revisions\/879"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/media\/1251"}],"wp:attachment":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=878"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=878"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=878"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}