RTF file creation

S

Srini

Hi All,

I am developing a component as a dll.In that i have to create a .rtf file.I
have created the .rtf file successfully
by using RTF Specifications.

void CTestRTFDlg::writeRTF(char *fname, int size)
{
CString str;
GetDlgItemText(IDC_RICHTEXTCTRL1,str);
FILE *f;
f=fopen(fname,"w+");

fprintf(f,"{\\rtf1\\ansi\\deff0{\\fonttbl{\\f0\\fswiss\\");
fprintf(f,"fprq2\\fcharset0 Arial;}");
fprintf(f,"{\\f1\\fnil\\fcharset0 Courier New;}}\n");
fprintf(f,"\\viewkind4\\uc1\\pard\\lang2058\\f0\\fs%d\n",52);
fprintf(f,"Multimedia Payphone Terminal\\fs052\\li520\\qc\\par\n");

fprintf(f,"\\viewkind4\\uc1\\pard\\lang2058\\f0\\fs%d\n",40);
fprintf(f,"____________________________________\\fs052\\li520\\par\n");

fprintf(f,"\\viewkind4\\uc1\\pard\\lang2058\\f0\\fs%d\n",30);
fprintf(f,"Sender's Name : \\fs052\\li520\\par\n");

fprintf(f,"\\viewkind4\\uc1\\pard\\lang2058\\f0\\fs%d\n",30);
fprintf(f,"Recipient Name : \\fs052\\li520\\par\n");

fprintf(f,"\\viewkind4\\uc1\\pard\\lang2058\\f0\\fs%d\n",30);
fprintf(f,"Fax # :
\\fs052\\li520\\par\n");

fprintf(f,"\\viewkind4\\uc1\\pard\\lang2058\\f0\\fs%d\n",30);
fprintf(f,"Subject :
\\fs052\\li520\\par\n");

fprintf(f,"\\viewkind4\\uc1\\pard\\lang2058\\f0\\fs%d\n",30);
fprintf(f,"Date & Time : \\chdate
\\chtime\\fs052\\li520\\par\n");

fprintf(f,"\\viewkind4\\uc1\\pard\\lang2058\\f0\\fs%d\n",40);

fprintf(f,"____________________________________\\fs052\\li520\\par\\par\n");

fprintf(f,"\\viewkind4\\uc1\\pard\\lang2058\\f0\\fs%d\n",30);
fprintf(f," "+str+"\\fs052\\li520\\par\n");

fprintf(f,"\\f1\\fs024\\par\n}");
fclose(f);
}
while creating the file it shows a dialog for a while and immediately
disappearing. if the above code
is written in a dialog based application(EXE), it works fine.


If I create .txt file, it works fine.

ofstream f1("FaxDocument.txt");
f1.write(FaxContent, lstrlen(FaxContent));
f1.close();
Can anyone plz suggest me why it is happening and how can I get rid of this
dialog in my component?
I am very badly in need of it.

Any help appreciated.

Thanks & Regards
Srinivas
 
J

Jonathan West

Hi Srini,

Since you aren't using the VBA language in Word to create your component, I
think you have posted to the wrong group here. I suggest you re-post to one
of the C++ groups.
 
S

Srini

Hi Jonathan West,
How can I create .rtf file using VB? I have an option to create rtf file
using C++ or VB

I am very badly in need of it

Thanks & Regards
Srinivas
 
J

Jonathan West

Using Word VBA, create a Word document, and then use the SaveAs method to
save it as an RTF file.

But I suspect that isn't what you mean. There are a number of RTF controls
available, either commerically or for free. You might like to use one of
them. Do a google search for "RTF control"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top