Last active
September 6, 2016 21:47
-
-
Save b-/bf52c12645e7931b2faadefe45662708 to your computer and use it in GitHub Desktop.
make RTF from input ASCII text file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| set input="%~1" | |
| set output="%~1.rtf" | |
| ::RTF header and font table (Courier New) | |
| echo {\rtf1\ansi\deff0\nouicompat{\fonttbl{\f0\fnil\fcharset0 Courier New;}} > %output% | |
| ::page setup settings (landscape, legal, 0.5" margins) | |
| echo \landscape >> %output% | |
| ::Paper width and height and margins in "twips", or 20ths of a point, or 1/1440ths of an inch | |
| ::So legal paper (oriented in landscape) would be (14 inches * 1440 twips in an inch)=20160 twips long | |
| echo \paperw20160 >> %output% | |
| echo \paperh12240 >> %output% | |
| ::And a half-inch margin | |
| echo \margl720 >> %output% | |
| echo \margr720 >> %output% | |
| echo \margt720 >> %output% | |
| echo \margb720 >> %output% | |
| ::F0 (only font in the table, Courier New) at 16 "half points" (8 point font) | |
| echo \pard\f0\fs16\lang1033\par >> %output% | |
| ::Now read in the input file to the output file, adding \par after every line | |
| for /F "tokens=* delims=" %%A in (%input%) do (echo %%A\par >> %output%) | |
| ::And we end the RTF with a closing curly brace | |
| echo } >> %output% | |
| ::Open the file in the default editor | |
| start "" %output% |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
RTF 1.9 official specification:
https://www.microsoft.com/en-us/download/details.aspx?id=10725