I want to output code{formated with color} to a .doc{or .odt} file or an html file for a report....
How can i do this?
PS::tell me if i don't phrase the question well, so i can rephrase it!
I want to output code{formated with color} to a .doc{or .odt} file or an html file for a report....
How can i do this?
PS::tell me if i don't phrase the question well, so i can rephrase it!
you can't. files know nothing about colors and fonts. The best you can do is use some sort of color tags that is recognized by the program that reads the file -- for example Notepad doesn't recognize any, but the browser might if you use color html tags.
By, DOC I suppose you mean document file(MS Word). To generate that kind of file you will need some library. I dont know if there is any free available but you could look into OpenOffice source code to see how they read doc file.
Yo generate html with colour its pretty simple. For eample to print something in red you could simple generate html code and save it into html file:
/* if data stroed in array you you continuosly iterate through it*/
file << "<span style=\"color: #0000FF\">" << data[i] << "</span><br/>";
what i have in mind is:::
if you take an html page and coy it to word or openoffice writer it retains the text colors....
so i was wondering if there is a way to output to an html page and then copy paste it to my document...
html files are just plain text files that contain html markup code. You can certainly do that with a c++ program. You can also create the document file providing you use Microsoft's Office Automation libraries or possibly the OpenOffice that was previously mentioned.
what i have in mind is:::
if you take an html page and coy it to word or openoffice writer it retains the text colors....
so i was wondering if there is a way to output to an html page and then copy paste it to my document...
If you mean copying through C++, then Ancient Dragon has given nice piece of advice otherwise if you mean copying later like a normal guy.
Then there is no relationship between DOC files and HTML files. All depends upon the word processor. But the good thing is that whenever you copy webpage from browser to word, the text remain somewhat same.
Generally problem comes when you use complex stylesheet. For a simple page or pure html I think there comes no problem.
yes, that is why i am asking for a way to output my code to html...
PS:: i don't want my programm output to be html... i want to output the source code to html....color formatted
HTML file are simple text files, with extension .htm or .html. When you open it with browser you see it formatted and when you open it with notepad or any other editor you see its source code. Browser parse the HTML code.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.