text background color in RTF - html

For some reasons, I need to export RTF data (no images, text-only) from an iOS application to be able to read it in Word or any word processor. For now, this export creates a RTF file that can be read in TextEdit or Word (MacOS & Windows), showing the background color of the original text. Both can read and display correctly the text as it was displayed on the iPhone UIWebView.
But unfortunately, when trying to read this RTF as an input to my iPhone application (and as a quick look provided by iOS in email application), the text color is OK but the background color doesn't display.
When analyzing the HTML created by UIWebView after importing this exported RTF data, I can see that no information about text background color has been kept by iOS's import feature (that is quite logical since the same background color is not displayed by "quick look" feature in iOS email application).
After hours spent to analyze Word RTF version of a document, I couldn't find the good way to code my RTF for background color compatibility. RTF specification speaks about \cbN to put background color to the Nth color of the color table. As Word doesn't implement this \cbN control, I implemented the \chcfpat0\chcbpatN\cbN control to keep compatibility with MacOS TextEdit and Word software (any platform). And it works. But the RTF import tool in iOS neither recognize \chcfpat0\chcbpatN nor \cbN keywords.
Does anybody has any magic idea to deal with that silly problem?
Thanks

I always use WordPad when trying to create simple RTF-formatted documents. Most of the time, I'm trying to display formatted text in a WinForms application, and need something that the RichTextBox control can handle being assigned to its Rtf parameter.
WordPad calls the background color the "text highlight color".
I just used this to display some rich-text in a RichTextBox control with a black background-color. I set the text-highlight-color to black, and the text-color to white, inside WordPad, saved the document, opened the document in Notepad, copied the raw RTF text from there, and assigned it to the Rtf property of a RichTextBox control, and it worked fine.
Hopefully this technique will work in your situation.

Related

Transforming Wysiwig HTML to PDF output

Using "wkhtmltopdf" as a PDF generator, and CKeditor as a Wysiwig editor, the font-size looks different between what I see in my browser, and what is shown in the PDF.
I tried many things: changing the font-size to cm/px/pt, changing the font-size percentage on the body ... but I can't find a way to have the same look in my HTML editor and in my PDF.
Is there some kind of link between PDF font-size and html one's ? Is the output in a PDF smaller than the one in a browser ?
Does someone already managed to obtain the same look in a WebBrowser than in a PDF using those kind of PDF generation tool ?
I found a satisfying solution.
I tried to import font using #font-face, but this doesn't work for me, because multiple #font-face for each "style" (italic, bold, bold+italic) was not recognized by wkhtmltopdf.
I had to use a "free" font ("DejaVu Sans" in my case) that was available on my Windows system and on the Linux Server and is directly available by the system when it generates the PDF.
Those two fonts now renders similarly between my Wisywig and the PDF generated. I also had to use a lot of CSS rules to make it clean, removing PNG images ... but that's another story.

HTML to PDF convertion and editing in iOS

I am creating an iPad application for reading PDF, this PDF should be generated from a HTML file. I have seen some sample codes for converting HTML to PDF, and I think that part will be fine for me to implement.
I have seen some apps from from AppStore for reading PDF files, in that there is an option for increase the font size (not zooming), color style etc. When we increase the font size the text content automatically wrapping to next line. How can I implement this in my app? Any idea about how would they have done that?
I have seen in some posts that, it is not possible to edit a PDF file, so are they actually using PDF file or some other format?
When rendering your PDF to show it to user, you can convert it in other formats like HTML and then allow user to change font-size, font-style. So your PDF remain unchanged. Also it is easy to manipulate HTML than binary formatted documents like PDF.

html restrictions in ics file

I'm developing a function (C#, ASP.NET 4) which creates and downloads a .ics file.
I'm trying to figure out what restrictions there are on the html within the X-ALT-DESC property. For example, if I send this:
X-ALT-DESC;FMTTYPE=text/html:<html><body><ul><li style="font-weight:bold">#1</li><li>#2</li></ul><table border=1><tr><td>table test</td></tr></table><span style="font-weight:bold">Site Visit Agenda</span><br/><span>8:00 AM</span><br/><span>Check in with management<br/>Facility Inspection<br/>Training and Meeting Setup</span></tr></table></body><html>
When I open the downloaded file, it opens in Outlook 2010, so that seems o.k. While the list stuff renders as I'd expect, the table border doesn't show, nor do either of the font-weight settings get rendered. (On the plus side, the html tags aren't rendered as text, it just doesn't format the alt desc like you'd see in a browser with the same HTML).
Of course, we're trying to figure out what HTML we can and cannot use to format the information we want to show up in the alt description.
Searching around, I can't find anything which talks about what's allowed and what isn't.
Thanks to anyone who has a pointer.

Display/Render RTF doc in browser display using html textarea or something similar

My web application has an feature wherein preformatted RTF documents are used as templates and the user can select the source of data and then merge with the RTF documents templates to create merged RTF files. The RTF templates have placeholders which get replaced with user selected content. The final doc can either be saved or opened directly if word/wordpad is available on the local users machine.
Now, I have a requirement to display the merged document to the user for confirmation. The user may either print or save the document to the system directly. The display should not be word/wordpad application but should be within the application itself, using textarea or something similar to render the document. Can you please let me know if its possible to render the RTF document in textarea or not. Along with the displayed content, there should be options to print and save the document.If I have to convert the RTF to Html and then display the html content in textarea , please let me know how i can do the conversion and then display the html in the page.
That's a very difficult requirement. First of all, let's dismiss the idea about a <textarea>, because it does not support any formatting at all. All the WYSIWYG editors you've seen out there are based on <iframe>s.
Secondly, no browser can directly display a RTF. You can embed it as an <object>, and some might show it (IE probably will), but I can't say which ones won't. Portable devices almost certainly won't. But you should test this though, maybe it works well enough after all.
Failing that, HTML conversion is also out of question, because RTF has very very many features that cannot be emulated in HTML. There are some converters out there (google), but but they will all come with serious limitations. If you want full support, you will have to do your own rendering via Canvas or Flash or something.
To this end I'd suggest checking out Google Docs. They've gone through all of this hassle and have a rather feature-full engine for displaying most possible documents. I think it was also possible to embed them in your own webapges, though I've never checked it out myself.
Use a <PRE> tag to Display/Render RTF doc in browser.

Any good way to convert html table (with colored text, images, etc) to Word, pdf, or Excel

I have a html table. Inside the table are images, links (different font colors, etc). What is the easiest way to get this exported into an ms office format (powerpoint, excel, word, pdf)? I was going to start hand writing this but figured I would throw out this question if there was any thing that would help with this conversion . . . my really low budget solution is to take a screen shot and resize to fit on a page!
You can install a PDF printer and open the html in a browser, then choose print, as if to a normal printer, and the output is converted into a pdf.
For windows you can download and install from this page:
http://www.cutepdf.com/products/cutepdf/writer.asp
This software:
http://www.cutepdf.com/download/converter.exe
http://www.cutepdf.com/download/CuteWriter.exe
For other operating systems it is probably a built in feature when you try to print.
It doesn't always work perfectly, but most of the time I can open any html files I have in adobe, and it will auto convert them to pdf and you can save, usually everything looks the way it should. You can also just open the html in word, but it doesn't work so well if you are using any css.
This page has information on transforming XML to Word XML format: http://www.linkwerk.com/pub/xml/invitation/xml2wordml/
I haven't used it, but perhaps it will be helpful.