rtf

Insert an image into RTF document in C#

拈花ヽ惹草 提交于 2019-12-06 04:44:51
问题 I am creating a RichTextBox subclass that can insert images easily. I referred to this question to start, but I can't get the generated RTF string to work. When I try to set the SelectedRtf of the RTB, it errors out with "File format is not valid." Here is my code: internal void InsertImage(Image img) { string str = @"{\pict\pngblip\picw24\pich24 " + imageToHex(img) + "}"; this.SelectedRtf = str; // This line throws the exception } private string imageToHex(Image img) { MemoryStream ms = new

Why do hyperlinks sometimes not show in an NSTextField with an NSAttributedString?

天大地大妈咪最大 提交于 2019-12-06 03:04:31
问题 The text I use in an NSTextField is loaded from a file as follows. NSString *path = [[NSBundle mainBundle] pathForResource:@"Credits" ofType:@"rtf"]; NSAttributedString *as = [[NSAttributedString alloc] initWithPath:path documentAttributes:NULL]; [creditsLabel setAttributedStringValue:as]; [creditsLabel becomeFirstResponder]; The hyperlinks in the window don't render in blue underline unless I first click somewhere on the NSTextField, as per the two screenshots. How can I make these

Strange shift when Selecting text in richtext box v5 that contains hyperlinks

冷暖自知 提交于 2019-12-06 02:32:43
问题 When I use the RichTextBox.Select(int start, int length) function to select text in a rich text box that contains hyperlinks, there is some shift in the selection when I try to select any text that is after the hyperlink. When I remove the hyperlink, the selection works properly. Edit: I use RichTextBox 5 (the default in Visual Studio is version 4) public class RichText50W : RichTextBox { [DllImport("kernel32.dll", CharSet = CharSet.Auto)] static extern IntPtr LoadLibrary(string lpFileName);

Convert HTML to RTF in java?

隐身守侯 提交于 2019-12-06 01:25:03
I need to convert HTML to RTF, and I am using this code: private static String convertToRTF(String htmlStr) { OutputStream os = new ByteArrayOutputStream(); HTMLEditorKit htmlEditorKit = new HTMLEditorKit(); RTFEditorKit rtfEditorKit = new RTFEditorKit(); String rtfStr = null; htmlStr = htmlStr.replaceAll("<br.*?>", "#NEW_LINE#"); htmlStr = htmlStr.replaceAll("</p>", "#NEW_LINE#"); htmlStr = htmlStr.replaceAll("<p.*?>", ""); InputStream is = new ByteArrayInputStream(htmlStr.getBytes()); try { Document doc = htmlEditorKit.createDefaultDocument(); htmlEditorKit.read(is, doc, 0); rtfEditorKit

Document support (rtf, doc, docx) for UWP/Windows 10 Mobile

孤街醉人 提交于 2019-12-05 19:47:15
How can I display documents (doc, docx, rtf) in an UWP app? The WebView isn't able to do this. Other options would be calling an external application with Windows.System.Launcher.LaunchUriAsync (e.g. Word) or using a 3rd party library. The requirement is to have the data in the app, because you don't have control over it, if it's handled to another one. Another option would be to convert it to another format (e.g. PDF) which UWP can handle (not really). Any ideas? If you would like to display word or pdf files in the UWP app you can use WebView control with Google Docs Viewer - I was using it

Simple way to reading/writing NSAttributedString in iOS?

空扰寡人 提交于 2019-12-05 15:11:00
In Mac OS X, there is AppKit addition which supports reading and writing of NSAttributedString as RTF format. Equivalent in iOS? Should I make my own? Do you just want to save the string to the disk? I would use NSCoding for that. To write an object to a file: result = [NSKeyedArchiver archiveRootObject:attributedString toFile:archivePath]; To read an object from a file: attributedString = [NSKeyedUnarchiver unarchiveObjectWithFile:archivePath]; You can do this with any object conforming to "NSCoding", and it's fairly easy to add support for NSCoding to your own classes. More information can

RichTextBox (.NET Winforms) problem (or alternative)

孤人 提交于 2019-12-05 11:04:41
I have a problem with .Net's RichTextBox control. It seems that it doesn't support table cell formatting, which is funny because most of the time I create tables I want the cell contents to be right-aligned (numbers, currency). If I try to open a WordPad document in RichTextBox, it ignores (and actually removes ) the commands for cell alignment. I tried several workarounds but didn't succeed. Can anyone think of an idea to fix this? (without using fixed-width fonts and spaces) This would be the best solution since other code is working fine already, so if only thing needed is a dirty hack, it

How to display .rtf file inside TextView?

笑着哭i 提交于 2019-12-05 01:28:41
my app needs to display custom text saved in a bunch of .rtf files inside a TextView. I have searched in different forums and i still don't have a clear solution. It seems pretty easy right? i have developed a few apps like this in iOS and i had no problems displaying .rtf text inside a UITextView as an attributed string. I thought in Android will be easier. Thanks for your time It seems pretty easy right? Not especially. Heck, even Windows largely abandoned RTF a decade or so ago. Option #1: If you were planning on packaging the RTF in the app itself (e.g., as raw resources or assets), get

Why is my license not showing up?

不想你离开。 提交于 2019-12-05 00:58:19
In my <Product> I have: <WixVariable Id="WixUILicenseRtf" Value="LICENSE.rtf" /> LICENSE.rtf exists, and is an rtf file (I've tried saving with a few different programs in case it was a problem with one of them). The file contains text (a whole license!), and the text is sensibly formatted. Why then, is the License field of my installer blank? It turns out you basically must generate your rtf with Wordpad, or make a perfect replica. Since mine are generated by scripts, I adjusted my script to insert the Wordpad header to the rtf file, and this fixed it. 来源: https://stackoverflow.com/questions

Inno Setup - How to change the color of the hyperlink in RTF text?

强颜欢笑 提交于 2019-12-04 18:17:58
I'm using code from How to add clickable links to custom Inno Setup WelcomeLabel? : procedure InitializeWizard; var RichViewer: TRichEditViewer; begin RichViewer := TRichEditViewer.Create(WizardForm); RichViewer.Left := WizardForm.WelcomeLabel2.Left; RichViewer.Top := WizardForm.WelcomeLabel2.Top; RichViewer.Width := WizardForm.WelcomeLabel2.Width; RichViewer.Height := WizardForm.WelcomeLabel2.Height; RichViewer.Parent := WizardForm.WelcomeLabel2.Parent; RichViewer.BorderStyle := bsNone; RichViewer.TabStop := False; RichViewer.ReadOnly := True; WizardForm.WelcomeLabel2.Visible := False;