 |
|
 |
My project work perfect on XP but on a clean Windows 7 (32 bits) with NO WORD or NO MS Office products installed, i get no tables... no errors either...? Anyone seen this?
|
|
|
|
 |
|
 |
how to apply to the table, click "auto-fit the width of the window?"
|
|
|
|
 |
|
 |
I hope, suggest new ideas. Thanks Paolo Gios for article.
TR: Umarım yararlı olur. Sizin çözümünüz varsa gönderin.
// WordDocument.cs
#region calculated properties
internal string Header
{
get
{
return @"{\rtf1\ansi\ansicpg1254\deff0\deflang1055{\fonttbl{\f0\fnil\fcharset162{\*\fname Arial;}Arial TUR;}{\f1\fnil\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\sa200\sl276\slmult1\f0\fs22";
}
}
// Utulity.cs
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 == ' ') sb.Append(c);
else
{
switch (c)
{
case '€':
sb.Append("\\'80");
break;
case 'ç':
sb.Append("\\'e7");
break;
case 'ö':
sb.Append("\\'f6");
break;
case 'ı':
sb.Append("\\'fd");
break;
case 'ş':
sb.Append("\\'fe");
break;
case 'ü':
sb.Append("\\'fc");
break;
case 'ğ':
sb.Append("\\'f0");
break;
case 'Ç':
sb.Append("\\'c7");
break;
case 'Ö':
sb.Append("\\'d6");
break;
case 'İ':
sb.Append("\\'dd");
break;
case 'Ş':
sb.Append("\\'de");
break;
case 'Ü':
sb.Append("\\'dc");
break;
case 'Ğ':
sb.Append("\\'d0");
break;
default:
{
byte[] Bytes = ue.GetBytes(new char[] { c });
string tmp = "\\'" + Utility.ToHexString(Bytes[0]);
sb.Append(tmp);
}
break;
}
}
}
return sb.ToString().Replace("\r\n","\\par").Replace("\n","\\par ");
}
Divinum est sedare dolorem
|
|
|
|
 |
|
 |
How do I set the First Page Header Or Footer Different with other pages on word document by using this library? like doc.PageSetup.DifferentFirstPageHeaderFooter = -1;
modified on Friday, July 24, 2009 4:24 PM
|
|
|
|
 |
|
 |
Hi,
Library looks great. I was wondering if you have ever had to modify the library to enable the opening of a RTF or word "template"?
Thanks,
Tom.
|
|
|
|
 |
|
 |
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
|
|
|
|
 |
|
 |
Confirmed. I got the same problem. Can someone help us?
|
|
|
|
 |
|
 |
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
|
|
|
|
 |
|
 |
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});
|
|
|
|
 |
|
 |
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
|
|
|
|
 |
|
 |
Hi,
I want to know the page current number. Someone helps me please,
Thanks in advance,
|
|
|
|
 |
|
 |
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
|
|
|
|
 |
|
 |
Ok, thank you for answering.
Anyway, your library is great ! Thank you
|
|
|
|
 |
|
 |
Hi,
try insert in WordDocument.cs this :
public void CurrentPage() // page current number
{
this.Write("\n\\chpgn\n",false);
}
public void NumOfPages()
{
this.Write("\n{\\field{\\fldinst NUMPAGES \\*PAGE}}\n", false); // and number of pages in document
}
Only one note - this'll work only in footer or header
|
|
|
|
 |
|
 |
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.
|
|
|
|
 |
|
 |
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
|
|
|
|
 |
|
|
 |
|
 |
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);
}
|
|
|
|
 |
|
 |
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.
|
|
|
|
 |
|
 |
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
|
|
|
|
 |
|
|
 |
|
 |
Thanks alot.
|
|
|
|
 |
|
 |
Thank you, solved problem with russian encoding as well.
|
|
|
|
 |
|
 |
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");
|
|
|
|
 |
|
 |
Try putting a WriteLine after the newPage.
|
|
|
|
 |