Formatting rtf file in Java -
ok i'm trying create .rtf
file using java
. didn't know syntax did created rtf file using textedit on mac opening plaintext see code. used create output method followed:
/* creates rtf */ public string creatertf(){ string l1 = "{\\rtf1\\ansi\\ansicpg1252\\cocoartf1265\\cocoasubrtf190 \n\n"; string l2 = "{\\fonttbl\\f0\\fmodern\\fcharset0 courier;} \n\n"; string l3 = "{\\colortbl;\\red255\\green255\\blue255;} \n\n"; string l4 = "\\margl1440\\margr1440\\vieww10800\\viewh8400\\viewkind0 \n\n"; string l5 = "\\pard\\tx720\\tx1440\\tx2160\\tx2880\\tx3600\\tx4320\\tx5040\\tx5760\\tx6480\\tx7200\\tx7920\\tx8640\\pardirnatural \n\n"; string l6 = "\n\n"; string l7 = "\\f0\\fs24 \\cf0 original sequences:\\ \n\n"; string l8 = "\\ \n\n"; string l9 = sequence1 + "\\ \n\n"; string l10 = sequence2 + "\\ \n\n"; string l11 = "\\ \n"; string l12 = "alignment:\\ \n\n"; string l13 = "\\ \n\n"; string l14 = s1align + "\\ \n\n"; string l15 = aligned + "\\ \n\n"; string l16 = s2align + "\\ \n\n"; string l17 = "\\ \n\n"; string l18 = "score: " + score + "}"; string rtfstring = l1 + l2 + l3 + l4 + l5 + l6 + l7 + l8 + l9 + l10 + l11 + l12 + l13 + l14 + l15 + l16 + l17 + l18; return rtfstring; }
i know it's little sloppy trying specific possible , separate lines because when manually made file in textedit rtf code was:
{\rtf1\ansi\ansicpg1252\cocoartf1265\cocoasubrtf190 {\fonttbl\f0\fmodern\fcharset0 courier;} {\colortbl;\red255\green255\blue255;} \margl1440\margr1440\vieww10800\viewh8400\viewkind0 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural \f0\fs24 \cf0 original sequences:\ \ acgttgtacca\ agttaaaccgtaaa\ \ alignment:\ \ acgttgtacc--a--\ | ||| ||| | \ a-gttaaaccgtaaa\ \ score: 3}
my problem how rtf code looks when save file using program, when open formatted file using textedit it's 1 continuos string not separated lines want it. funny thing when add line breaks myself in textedit save rtf code looks same. tried adding 2 /n/n
@ end of strings didn't work. there way accomplish output?
use \r\n
instead of \n
. should fix problem.
Comments
Post a Comment