{"id":1196,"date":"2018-01-19T19:22:33","date_gmt":"2018-01-19T19:22:33","guid":{"rendered":"http:\/\/goofy-trucks.flywheelsites.com\/using-php-for-rtf-page-4\/"},"modified":"2018-01-19T19:24:36","modified_gmt":"2018-01-19T19:24:36","slug":"using-php-for-rtf-page-4","status":"publish","type":"post","link":"https:\/\/phpbuilder.com\/using-php-for-rtf-page-4\/","title":{"rendered":"Using PHP for RTF Page 4"},"content":{"rendered":"<div class=\"phpbuilder-content\">\n<div class=\"phpbuilder-meta\">\n<div class=\"\">By Sujith Nair<\/div>\n<div class=\"\">on May 22, 2002<\/div>\n<\/p><\/div>\n<div id=\"overflow-content\">\n<div class=\"articlePara\">\nAnother alternative for defining the scope is by closing the control<br \/>\nwith a &#8216;0&#8217;. That is,<br \/>\nwhen such a control word (like b) has no parameter or has a nonzero<br \/>\nparameter (like b1), it is assumed<br \/>\nthat the control word turns on the property. When such a control word<br \/>\nhas a parameter of 0 (like b0),<br \/>\nit is assumed that the control word turns off the property. For example,<br \/>\nb turns on bold, whereas b0<br \/>\nturns off bold. It&#8217;s not over yet. The most important part is, we have to<br \/>\ntake care of all the &#8220;n&#8221;, &#8220;r&#8221;<br \/>\nand &#8220;t&#8221;s in the document. Best way to deal with it is to escape all<br \/>\n&#8220;&#8221;s preceding &#8216;r&#8217;,&#8217;n&#8217; and &#8216;t&#8217; before<br \/>\nwriting to a file. For newlines we can make use of &#8220;par&#8221;.\n<\/div>\n<div class=\"articlePara\">\nNow I was left with only one thing: to send email attachment of RTF<br \/>\nfiles. After I<br \/>\nwas able to write an RTF file, it didn&#8217;t seem difficult. All I did<br \/>\nwas define a<br \/>\nContent-Type of &#8220;multipart\/mixed&#8221; as parent, &#8220;text\/plain&#8221; for message<br \/>\nand &#8220;text\/rtf&#8221; for<br \/>\nthe attachment. I will show you how.\n<\/div>\n<div class=\"articlePhpEx\">\n<font face=\"courier\"><code><span style=\"color: #000000\"><\/p>\n<p><span style=\"color: #0000BB\">&lt;?php<\/p>\n<p><\/span><span style=\"color: #FF8000\">\/\/\u00a0the\u00a0preceding\u00a0part\u00a0of\u00a0the\u00a0mail\u00a0remains\u00a0as\u00a0same\u00a0as\u00a0that\u00a0of\u00a0a\u00a0normal<br \/>\n<br \/>\/\/\u00a0mail.<\/p>\n<p><\/span><span style=\"color: #0000BB\">fputs<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$fd<\/span><span style=\"color: #007700\">,\u00a0<\/span><span style=\"color: #DD0000\">\"Content-Type:\u00a0multipart\/mixed;\u00a0boundary=$boundry\u00a0nn\"<\/span><span style=\"color: #007700\">);<br \/>\n<br \/><\/span><span style=\"color: #0000BB\">fputs<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$fd<\/span><span style=\"color: #007700\">,\u00a0<\/span><span style=\"color: #DD0000\">\"Content-Transfer-Encoding:\u00a07bit\u00a0n\"<\/span><span style=\"color: #007700\">);<br \/>\n<br \/><\/span><span style=\"color: #0000BB\">fputs<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$fd<\/span><span style=\"color: #007700\">,\u00a0<\/span><span style=\"color: #DD0000\">\"This\u00a0is\u00a0a\u00a0multi-part\u00a0message\u00a0in\u00a0MIME\u00a0format\u00a0nn\"<\/span><span style=\"color: #007700\">);<br \/>\n<br \/><\/span><span style=\"color: #0000BB\">fputs<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$fd<\/span><span style=\"color: #007700\">,\u00a0<\/span><span style=\"color: #DD0000\">\"--$boundry\u00a0n\"<\/span><span style=\"color: #007700\">);<br \/>\n<br \/><\/span><span style=\"color: #0000BB\">fputs<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$fd<\/span><span style=\"color: #007700\">,\u00a0<\/span><span style=\"color: #DD0000\">\"Content-type:\u00a0text\/plain;\u00a0charset=us-ascii\u00a0n\"<\/span><span style=\"color: #007700\">);\u00a0<br \/>\n<br \/><\/span><span style=\"color: #0000BB\">fputs<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$fd<\/span><span style=\"color: #007700\">,\u00a0<\/span><span style=\"color: #DD0000\">\"Content-Transfer-Encoding:\u00a07bit\u00a0n\"<\/span><span style=\"color: #007700\">);<br \/>\n<br \/><\/span><span style=\"color: #0000BB\">fputs<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$fd<\/span><span style=\"color: #007700\">,\u00a0<\/span><span style=\"color: #DD0000\">\"n\"<\/span><span style=\"color: #007700\">);<br \/>\n<br \/><\/span><span style=\"color: #0000BB\">fputs<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$fd<\/span><span style=\"color: #007700\">,\u00a0<\/span><span style=\"color: #DD0000\">\"\u00a0message\u00a0is\u00a0thisn\"<\/span><span style=\"color: #007700\">);\u00a0<\/span><span style=\"color: #FF8000\">\/\/\u00a0message\u00a0goes\u00a0here<br \/>\n<br \/><\/span><span style=\"color: #0000BB\">fputs<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$fd<\/span><span style=\"color: #007700\">,\u00a0<\/span><span style=\"color: #DD0000\">\"--$boundry\u00a0n\"<\/span><span style=\"color: #007700\">);<\/p>\n<p><\/span><span style=\"color: #0000BB\">fputs<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$fd<\/span><span style=\"color: #007700\">,\u00a0<\/span><span style=\"color: #DD0000\">\"Content-type:\u00a0application\/rtf;\u00a0charset=us-ascii\u00a0n\"<\/span><span style=\"color: #007700\">);\u00a0<br \/>\n<br \/><\/span><span style=\"color: #0000BB\">fputs<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$fd<\/span><span style=\"color: #007700\">,\u00a0<\/span><span style=\"color: #DD0000\">\"Content-Transfer-Encoding:\u00a07bit\u00a0n\"<\/span><span style=\"color: #007700\">);<br \/>\n<br \/><\/span><span style=\"color: #0000BB\">fputs<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$fd<\/span><span style=\"color: #007700\">,\u00a0<\/span><span style=\"color: #DD0000\">\"Content-Disposition:\u00a0inline;\u00a0filename=\"mailer.rtf\"\u00a0n\"<\/span><span style=\"color: #007700\">);<br \/>\n<br \/><\/span><span style=\"color: #0000BB\">fputs<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$fd<\/span><span style=\"color: #007700\">,\u00a0<\/span><span style=\"color: #DD0000\">\"Content-Base:\u00a0\"file\/\/\/c|\/temp\/mailer.rtf\"\u00a0rnrn\"<\/span><span style=\"color: #007700\">);<\/p>\n<p><\/span><span style=\"color: #FF8000\">\/\/\u00a0the\u00a0succeeding\u00a0part\u00a0of\u00a0the\u00a0mail\u00a0remains\u00a0as\u00a0same\u00a0as\u00a0that\u00a0of\u00a0a\u00a0normal<br \/>\n<br \/>\/\/\u00a0mail.<br \/>\n<br \/><\/span><span style=\"color: #0000BB\">?&gt;<br \/>\n<br \/><\/span><br \/>\n<\/span><br \/>\n<\/code><\/font><\/p>\n<\/div>\n<p><\/div>\n<p><\/p>\n<div style=\"float: left; padding:15px; color:#17AAF3\">\n<div style=\"float:left; padding:2px;\"><a class=\"paginationPageLink\" href=\"nair200205239ba9.html?page=3\">\u00ab Previous Page<\/a><\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"nair20020523.html\">1<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"nair200205234658.html?page=2\">2<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"nair200205239ba9.html?page=3\">3<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"background-color:#B6E5FC; font-size:16px; margin-top:1px; padding:1px 4px 1px 4px; color:#000; font-style:bold; float:left;\">4<\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"nair20020523af4d.html?page=5\">5<\/a> <\/div>\n<div style=\"float:left; padding:2px;\"><a class=\"paginationPageLink\" href=\"nair20020523af4d.html?page=5\">Next Page \u00bb<\/a><\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Recently, I had a brief stint with RTF (Rich Text Format) files. I had to write an RTF file and send an RTF file as attachment in mail. Initially it<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1196","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/comments?post=1196"}],"version-history":[{"count":1,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1196\/revisions"}],"predecessor-version":[{"id":3103,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1196\/revisions\/3103"}],"wp:attachment":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/media?parent=1196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/categories?post=1196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/tags?post=1196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}