Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi All, Is there a way to format letters in c++?

If I output a text into a word document, is there a simple way to change the colour, font size etc ?
Posted
Comments
nv3 27-Jun-12 5:48am    
By "letters" you mean documents, as in a letter from person to person? How about generating a PDF document instead of a MS Word document? For generating PDFs you find various libraries on the Internet, some of them for free.
Sumal.V 27-Jun-12 5:54am    
Well not thought about generating letters in programming yet! ;)

I meant letters in a 'text'. I generate a report into word, say the date, name of the project and the specifications, while outputting in a string, can I apply any formatting ? changing font colour or making it bold..
enhzflep 27-Jun-12 7:18am    
Have a look into CreateFont
nv3 27-Jun-12 7:20am    
A simple text file does not contain any markup for color, bold, etc.. Of course, MS Word can read a plain text file, but then you have not color, font choice etc..

If you are thinking about writing a genuine MS Word document, you will be surprised about how complex a MS Word file is.
Sumal.V 27-Jun-12 9:38am    
Yeah I understand, just thought there might be a way to do that.

1 solution

You may use plain text formats like HTML and Rich Text that support formatting and can be read by word processing applications.

However, you must add the formatting sentences when creating your strings within C++. This is not very difficult for simple formatting, but can become complicated when using sophisticated formatting. Use HTML if it matches your requirements because the format is simpler and the plain text is better readable.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900