Print RTF

There is a inherited RichTextBox control class available from MS that implements FormatRange API which lets you with ease print rich formatted text from the control, see Getting WYSIWYG Print Results from a .NET RichTextBox

Alternative is a real painful lots of work analyzing each characters formatting, measuring size conseqences of different formatting and using this info with Graphics.DrawString (one call for each difference) when printing.
 
when i use this it works perfectly, except one thing, it is not getting the "Header" of the rft files i am trying to print. :confused: Any ideas of how to fix this?
 
"Header" ? Does there exist a sample document and/or a different explanation, because I don't know what you mean.
 
it's the same as a header in a word document where it is above the top margin. See Attached Example.
 

Attachments

  • ST1089.zip
    6.7 KB · Views: 26
just did some testing and WordPad also doesn't display the header, however MS Word does.

this is what the header looks like if viewed in the raw format

{\headerr \ltrpar \pard\plain \ltrpar\qc \li0\ri0\widctlpar\brdrb\brdrs\brdrw10\brsp100 \wrapdefault\faauto\rin0\lin0\itap0 \rtlch\fcs1 \af0\afs20\alang1025 \ltrch\fcs0
\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \ai\af0\afs36 \ltrch\fcs0 \i\fs36\insrsid13388587 1089 COLFAX & GAYLORD - Line Listing}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \fs24\insrsid13388587
\par }}
 
That doesn't appear to be a valid RTF document, the box errors when I try to load this as RTF. You don't have a rich document that display the "header" you talk about?
 
i removed some information from the attached file. maybe that's what corrupted the file. however i was able to display everything with in the body of the rtf just not the header.
 
Somehow, I didn't see the attached document of post 5 until now, actually I didn't see the post at all funnily, only the RTF codes of post 6, so that was what I replied to post 7.

I have now examined the uploaded .rtf document, here the header does not display in the RichTextBox, which suggests the format is incompatible. I can open it in WordPad to see the header there, also OpenOffice Writer displays the header fine. From WordPad I saved the file as a copy with its 'rich text format', the file size is now decreased from 67kb to 9kb, I have attached this file here and it displays the header when loaded into RichTextBox now. The original file must be coded by a newer RTF standard that can't be read with current rtf engine in .Net Framework.
 

Attachments

  • ST1089-2.zip
    1 KB · Views: 23
thanks for the help btw...
but in the file you attached the header has been stripped from the file.
this is starting to look like a lost cause... i think i just keep using MS Word in my program to print these files at work

if you figure anything out please post it =D
and ill do the same
 
That is very strange, because I see the header with that file, both in .Net 2.0 RichTextBox and WordPad. The Header is "Air Conditioning (2 hours)" right? That's the header I've been talking about at least.

Looking into the original file RTF codes I see "generator Microsoft Word 11.0.8125", I don't know this version, but you should see if it is possible to save as specific earlier version RTF for compability.
 
1089 COLFAX & GAYLORD - Line Listing
is the heading

I believe it is Office 2003 or maybe Office XP it has been opened with both. There is only one RTF option to save files in with word =\

Thanks again for your help

From what I can determine the only way to fix this is to add some code to the richtextbox control that allows it to read the header. I wouldn't even know were to start with something like that...lol
 
Back
Top