Saving rtf-file
-
Yes. The user, who opens the file must have Word or similar program to read the rtf-file. But, the user (end user), who creates the rtf-file with my application does not necessarily have MS Word.
The RTF specification is extensive, and programs that accept and/or generate RTF documents pick and choose what subset of commands they use. I performed a little test using Wordpad 6.0 (on Vista), creating, printing, storing and inspecting a simple RTF file both in portrait and in landscape. My observations include: - margin information was not stored in the document itself. - paper orientation was not stored in the document itself. - both are settings for Wordpad, not for the document; when you open Wordpad, you get what you had last time in Wordpad. As Wordpad seems to consider these app settings rather than document settings, I expect it will ignore the relevant commands if they were present in the file (I haven't tested this). FYI: Wordpad can show much more complex RTF documents than it allows the user to create; as an example, it can show tables, graphs, and images; things it doesn't offer the means for to insert in an empty document. :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
The RTF specification is extensive, and programs that accept and/or generate RTF documents pick and choose what subset of commands they use. I performed a little test using Wordpad 6.0 (on Vista), creating, printing, storing and inspecting a simple RTF file both in portrait and in landscape. My observations include: - margin information was not stored in the document itself. - paper orientation was not stored in the document itself. - both are settings for Wordpad, not for the document; when you open Wordpad, you get what you had last time in Wordpad. As Wordpad seems to consider these app settings rather than document settings, I expect it will ignore the relevant commands if they were present in the file (I haven't tested this). FYI: Wordpad can show much more complex RTF documents than it allows the user to create; as an example, it can show tables, graphs, and images; things it doesn't offer the means for to insert in an empty document. :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
Thanks for clarifying WordPad behaviour. So, the WordPad does not care about document page setting. But, if the user opens document for example with MS Word, then these settings coul be used. I managed to set the rtf-code by following way. I dont know whether it's clever way or not, but MS Word understood it and opened document in landscape. The created and saved rtf-file is reopened, page settings are inserted into rtf-code, and finally file is saved again.
Me.rtbPrint.SaveFile(Me.SaveFileDialog.FileName, RichTextBoxStreamType.RichText)
Dim FILE_NAME As String = Me.SaveFileDialog.FileName
Dim objReader As New System.IO.StreamReader(FILE_NAME)
Dim sString = objReader.ReadToEnd
objReader.Close()
sString = sString.Insert(6, "\paperw15840\paperh12240\margl720\margr144\margt720\margb288\lndscpsxn")
Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
objWriter.Write(sString)
objWriter.Close()Hope, that the code is seen properly.
-
Thanks for clarifying WordPad behaviour. So, the WordPad does not care about document page setting. But, if the user opens document for example with MS Word, then these settings coul be used. I managed to set the rtf-code by following way. I dont know whether it's clever way or not, but MS Word understood it and opened document in landscape. The created and saved rtf-file is reopened, page settings are inserted into rtf-code, and finally file is saved again.
Me.rtbPrint.SaveFile(Me.SaveFileDialog.FileName, RichTextBoxStreamType.RichText)
Dim FILE_NAME As String = Me.SaveFileDialog.FileName
Dim objReader As New System.IO.StreamReader(FILE_NAME)
Dim sString = objReader.ReadToEnd
objReader.Close()
sString = sString.Insert(6, "\paperw15840\paperh12240\margl720\margr144\margt720\margb288\lndscpsxn")
Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
objWriter.Write(sString)
objWriter.Close()Hope, that the code is seen properly.
I can't comment in any detail on Word as I avoid it as much as I can; I do know Word creates pretty complex output files (whether RTF or HTML), and behaves differently from one version to the next. FWIW: there are other RTF-compatible programs, such as WordPad++. They might offer the functionality you require without having the complexities and cost of Word. :)
Luc Pattyn [My Articles] Nil Volentibus Arduum