 |
|
|
Hi,
this looks like a great contribution, thanks a lot for making it available!
I do have a problem though. I am trying this with VS Express 2008. The example document works fine in Word, but when I try to open it in WordPad, the image won't show and the table looks different. Trying to display it within the program in a richTextBox - using richtextbox1.loadFile("example.doc") - the image also does not show and the table is corrupted, even though the file is saved as an RTF file.
Is there any thing I can do to make the output work with simpler RTF compatible tools than Word?
Any help is appreciated. I would like to use this to generate invoices directly from sales data (small scale bookstore), and don't want to send Word files as attachments, but just put the RTF within an e-mail.
Best regards Reiner
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Is it possible to render the rtf to an image using this library?
I loaded a rtf file in a richtextbox control and tried the following:
Gios.Word.WordDocument d = new WordDocument(WordDocumentFormat.Letter_8_5x11);
d.WriteRtf(richTextBox1.Rtf);
MemoryStream ms = new MemoryStream();
d.RenderToStream(ms);
Image img = Image.FromStream(ms);
img.Save("c:\test.bmp");
It threw an exception at Image.FromStream(ms) saying "Parameter is invalid". What is the output stream do? Do I need to use GDI+ to render it? If so how? Any insight would be good, I've been googling like crazy and not finding any source code to render an rtf.
Thanks in advance, Jose
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
Hi: I try to adjust the table size to full docuemnt length and align table to left. How do I change this code?
Thanks, Tai Fei Pao
WordTable rt = rd.NewTable(new Font("Arial", 12), Color.Black, 2, 9, 0); rt.SetColumnsWidth(new int[]{20, 20, 20, 20, 20, 20, 20, 20, 20});
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
It's impossible to create a TOC, so let user do it.
We create the entries, then let user right-click to see it :
Example code :
rd.WriteRtf(@"{\stylesheet {\style\s2 \ql\fi0\li0\ri0\f1\fs24\cf0 Normal;}
{\style\s0 \ql\fi0\li0\ri0\f0\fs22\cf0 toc 1;}
{\style\s5 \ql\fi0\li0\ri0\f1\fs26\b\cf0 heading 3;}
{\style\s4 \ql\fi0\li0\ri0\f1\fs28\b\i\cf0 heading 2;}
{\style\s1 \ql\fi0\li200\ri0\f0\fs20\cf0 toc 2;} {\style\s3 \ql\fi0\li0\ri0\f1\fs32\b\cf0 heading 1;} }
{\*\listtable } {\*\listoverridetable }
{\info} \paperw11907\paperh16840\margl720\margr720\margt720\margb720 \pgwsxn11907\pghsxn16840 \marglsxn720\margrsxn720\margtsxn720\margbsxn720\pard\plain\s2\fi0\li0\ri0\sl320\plain\f2{\field{\*\fldinst TOC \\f \\h \\u \\o 1-5 }{\fldrslt Right-click here and select Update to see the table of contents. }}
\par\pard\plain\s3\ql\fi0\li0\ri0\plain\f1\fs32\b\cf0 Heading 1");
Hope my solution is useful for someone
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
I'm sorry but it's not possible: word document has a flow layout, and the library cannot predict where the flow currently is.
Paolo
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
Your API is excellent. I need to generate a word document form with checkbox. How do I go about doing it? Is reading up on rtf specification but gotten lost. Please advise. Thank you.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
Hi i would like to create one RTF document with first page as portrait and second page as landscape... Is it possible??? Any help will be appreciated
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
Hey!
Your library didn't work with my unicode characters. To write an unicode character in RTF, you must write its decimal number with \u escape sequence.
So just replace the code in foreach statement in your utility's Encode function with this code: (You don't need special if for € sign anymore)
if ((c >= 48 && c <= 122) || c == '\n' || c == ' ' ) sb.Append(c); else { string tmp = "\\u" + (int)c + " "; sb.Append(tmp); }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Good point! Thank you! But it did work for me in this way:
string tmp = "\\u" + (int)c + "\\'ed"; I wanted to display Persian characters and it did not work as you pointed out, so I compared it with what WordPad generates and I found this. Hope to be useful for anybody trying to generate Persian or Arabic RTF.
|
| Sign In·View Thread·PermaLink | 1.80/5 (2 votes) |
|
|
|
 |
|
|
I spend sometime to find out how to fix for Vietnamese. This is my final result: internal static string Encode(string s) { s=s.Replace("\\","\\\\"); System.Text.StringBuilder sb=new System.Text.StringBuilder(); foreach (char c in s.ToCharArray()) { if ((c >= 48 && c <= 122) || c == '\n' || c == ' ' || c == '\t') { sb.Append(c); } else { if (c == '€') sb.Append("\\'80"); else { if (c < 256) { byte[] Bytes = ue.GetBytes(new char[] { c }); string tmp = "\\'" + Utility.ToHexString(Bytes[0]); sb.Append(tmp); } else sb.Append("\\u" + (int)c + "?"); } } } return sb.ToString().Replace("\r\n","\\par").Replace("\n","\\par ");
}
29718
|
| Sign In·View Thread·PermaLink | 4.00/5 (3 votes) |
|
|
|
 |
|
|
Hi, How to Make Table on Next Page ... I am usnig following code but it not working kindly help
WordDocument rd=new WordDocument(WordDocumentFormat.Letter_8_5x11_Horizontal); WordTable rr1=rd.NewTable(regular,Color.Black,1,1,0); rr1.SetColumnsWidth(new int[]{100}); rr1.Rows[0][0].Write("hello First Page"); rr1.SaveToDocument(10000,0);
rd.newPage(); WordTable rr2=rd.NewTable(regular,Color.Black,1,1,0); rr2.SetColumnsWidth(new int[]{100}); rr2.Rows[0][0].Write("hello Second Page"); rr2.SaveToDocument(10000,0);
rd.SaveToFile("..\\..\\Example2.doc");
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
Dear Friends,
Iam importing a Datatable which has around 45,000 rows of records. iam trying to export datatable to Word format but this operation is taking very long time and iam not getting the results. below is the code iam using
Dim WordDocumentFormat As Gios.Word.WordDocumentFormat Dim myWordDocument As New Gios.Word.WordDocument(WordDocumentFormat.Letter_8_5x11) Dim rt As Gios.Word.WordTable = myWordDocument.NewTable(New Font("Times New Roman", 12), Color.Black, dt.Rows.Count, dt.Columns.Count, 6) rt.Import(dt, 0, 0) Dim WordTextAlign As Gios.Word.WordTextAlign myWordDocument.SetFont(New Font("Comic Sans MS", 11, FontStyle.Bold)) myWordDocument.SetForegroundColor(Color.Black) myWordDocument.SetFontBackgroundColor(Color.White) myWordDocument.SetTextAlign(WordTextAlign.Left) rt.SetRowHeight(10) rt.SetContentAlignment(ContentAlignment.MiddleLeft) rt.SetColumnsWidth(New Integer() {1000, 400, 400, 1000}) rt.SaveToDocument(13000, 0) Dim frm As New Form1 myWordDocument.SaveToFile(frm.mysavefilepathword.FileName) RaiseEvent finishedwordwrite()
here DT is datatable whcih is very big in size. is there any way to optimize the code to reduce the time consumption for exporting to .DOC format.
Thanks, Mayur
-- modified at 0:12 Monday 9th July, 2007
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
In the WordDocument.cs I had to add some logic to SaveToStream to trim the size of the output. For some reason, it is padded with blanks. The bigger the document, the more blanks. Here's what I did:
public void SaveToStream(System.IO.Stream Stream) { Utility.Send(this.Header,Stream); System.IO.MemoryStream ms2=new System.IO.MemoryStream(); this.RenderToStream(ms2); Byte[] b=ms2.ToArray(); Stream.Write(b,0,b.Length); ms2.Close(); Utility.Send(this.Footer,Stream); //DGG - 6/28/2006 - Trimming output to reduce ultimate filesize. using (MemoryStream s = (MemoryStream) Stream) { s.Capacity = (int) s.Length; } }
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
How to Give Page Number on Generated Word Document Using like ...
I want to Give on the Footer " Page 1 of 3" (If document has 3 page and it show First Page like that.)
If any body have Idea please Reply ASAP.
Thanks & Regards
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
Hi,
I found a way to do this.
rd.FooterStart() rd.WriteControlWord("/Page " & _ "{\field{\*\fldinst PAGE}{\fldrslt 1}} of " & _ "{\field{\*\fldinst NUMPAGES}{\fldrslt 1}}") rd.FooterEnd()
This works for me.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
Dear Sir,
I want to change Background color of Specific Cell Iwrite a Code :
WordTable rt5 = rd.NewTable(regular, Color.Black, 50, 7, 0); rt5.SetColumnsWidth(new int[] { 12, 20, 12, 12, 12, 20, 12 }); rt5.Rows[0][0].Write("Product Code"); rt5.Rows[0][0].SetBackgroundColor(Color.Red); rt5.SaveToDocument(10000, 0);
But this code is not working.
Please reply ASAP
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |