{"id":291720,"date":"2019-07-06T09:01:04","date_gmt":"2019-07-06T09:01:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=291720"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=291720","title":{"rendered":"\u0420\u0435\u0446\u0435\u043f\u0442\u044b PostgreSQL: \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437 HTML \u0432 PDF"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\u0414\u043b\u044f \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437 HTML \u0432 PDF \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0441\u0430\u043c <a href=\"https:\/\/github.com\/RekGRpth\/postgres\">postgres<\/a> \u0438 \u0435\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 <a href=\"https:\/\/github.com\/RekGRpth\/pg_html2pdf\">pg_html2pdf<\/a>. (\u042f \u0434\u0430\u043b \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u0432\u043e\u0439 \u0444\u043e\u0440\u043a postgres, \u0442.\u043a. \u0434\u0435\u043b\u0430\u043b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u043e\u043f\u0438\u0445\u043d\u0443\u0442\u044c \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439. \u041c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <a href=\"https:\/\/hub.docker.com\/r\/rekgrpth\/postgres\">\u0433\u043e\u0442\u043e\u0432\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c<\/a>.)<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439   <\/p>\n<pre><code class=\"sql\">CREATE EXTENSION pg_html2pdf<\/code><\/pre>\n<p>  \u041d\u0443 \u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0430 \u043f\u043e\u0447\u0442\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/habr.com\/ru\/post\/456736\/\/\">pg_curl<\/a> \u0442\u0430\u043a  <\/p>\n<pre><code class=\"sql\">create or replace function send(url text, username text, password text, subject text, \"from\" text, \"to\" text, data text, type text) returns text language sql as $body$ with s as (select     curl.pg_curl_easy_init(),     curl.pg_curl_easy_reset(),     curl.pg_curl_easy_setopt('CURLOPT_VERBOSE', 1),     curl.pg_curl_easy_setopt('CURLOPT_URL', url),     curl.pg_curl_easy_setopt('CURLOPT_USERNAME', username),     curl.pg_curl_easy_setopt('CURLOPT_PASSWORD', password),     curl.pg_curl_recipient_append(\"to\"),     curl.pg_curl_header_append('Subject', subject),     curl.pg_curl_header_append('From', \"from\"),     curl.pg_curl_header_append('To', \"to\"),     curl.pg_curl_mime_data(data, type:=type),     curl.pg_curl_mime_data('\u0422\u0435\u0441\u0442 3', file:='=?utf-8?B?'||encode('\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 3.txt', 'base64')||'?=', type:='text\/plain; charset=utf-8', code:='base64'),     curl.pg_curl_mime_file(array['\/data\/\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430.txt', '\/data\/\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 2.txt'], file:=array['=?utf-8?B?'||encode('\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430.txt', 'base64')||'?=', '=?utf-8?B?'||encode('\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 2.txt', 'base64')||'?='], type:=array['text\/plain; charset=utf-8', 'text\/plain; charset=utf-8'], code:=array['base64', 'base64']),     curl.pg_curl_mime_data(html2pdf('&lt;p style=\"background-color: #c11\"&gt;\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439, \u043c\u0438\u0440!&lt;\/p&gt;'), file:='=?utf-8?B?'||encode('\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 2.pdf', 'base64')||'?=', type:='application\/pdf', code:='base64'),     curl.pg_curl_header_append('Connection', 'close'),     curl.pg_curl_easy_perform(),     curl.pg_curl_easy_getinfo_char('CURLINFO_HEADERS'),     curl.pg_curl_easy_cleanup() ) select pg_curl_easy_getinfo_char from s; $body$;<\/code><\/pre>\n<p>  \u0418 \u0432\u0441\u0451 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u0432 \u0444\u043e\u043d\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/habr.com\/ru\/post\/456722\/\">\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430<\/a>.<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/458986\/\"> https:\/\/habr.com\/ru\/post\/458986\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\u0414\u043b\u044f \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437 HTML \u0432 PDF \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0441\u0430\u043c <a href=\"https:\/\/github.com\/RekGRpth\/postgres\">postgres<\/a> \u0438 \u0435\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 <a href=\"https:\/\/github.com\/RekGRpth\/pg_html2pdf\">pg_html2pdf<\/a>. (\u042f \u0434\u0430\u043b \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u0432\u043e\u0439 \u0444\u043e\u0440\u043a postgres, \u0442.\u043a. \u0434\u0435\u043b\u0430\u043b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u043e\u043f\u0438\u0445\u043d\u0443\u0442\u044c \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439. \u041c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <a href=\"https:\/\/hub.docker.com\/r\/rekgrpth\/postgres\">\u0433\u043e\u0442\u043e\u0432\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c<\/a>.)  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-291720","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/291720","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=291720"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/291720\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=291720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=291720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=291720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}