Hi,
I am currently evaluating Aspose.Word as an addition to Aspose.Excel that we’re already using.
In order to stress Aspose.Word I have set up a sample application that mimics what our current production application does using RCW on MS Word.
NOTE: I will email a sample app and word documents to the word@aspose.com
email address
This is the application’s background:
Generate a Word document with a specific area (the only area formatted with the Standard style; all other areas are formatted using a special DO NOT TRANSLATE style) in which translators may enter their translations. Above this area there is some maintenance information. Also, add a couple of custom properties to identify the document once it gets sent back by translation services.
This is what the app does:
1 Load in a Template
2 Populate some maintenance field values in a top level tabel
3 Populate the original (to be translated text) into two fields. This text may wrap multiple lines
4 Set custom properties so that the document may be identified when received back from the translation service.
5 Save the document in a Word 97 compatible format
This is where the first problem arises: I can do 1-4 fine, even 5 is fine but only for Word 2002. When I load in the generated document into Word 97 the table looks distorted and background colors are mixed for some fields.
Now the document will be sent to a translation service, the one field will be changed/overwritten with the translation (in Standard style) and the document will be sent back to us. What the app needs to do now is
1 Read in the custom properties
2 Read/Concatenate all the text that is of style Standard
This is my second problem: I can read the properties without problems, but traversing paragraphs or finding paragraphs of a specific style seems impossible.
This is how I do it using RCW:
private string GetTranslationText(Word.Document document)
{
object what = Word.WdGoToItem.wdGoToLine;
object which = Word.WdGoToDirection.wdGoToFirst;
Word.Range range = document.GoTo(ref what, ref which, ref \_missing, ref \_missing);
Word.Find find;
object findText = "";
object forward = true;
object format = true;
object style = "Normal";
string retVal = null;
try
{
if (range == null)
{
return (retVal);
}
range.Select();
find = document.Content.Find;
find.ClearFormatting();
find.set_Style(ref style);
string text = "";
while (find.Execute(ref findText, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing,
ref forward, ref _missing, ref format, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing,
ref _missing) == true)
{
object unit = Word.WdUnits.wdParagraph;
object count = 1;
range = (Word.Range)find.Parent;
if (Convert.ToString(range.Text).Equals("\r") == true)
{
break;
}
text += Convert.ToString(range.Text);
range.Move(ref unit, ref count);
}
// Convert the text to the current code page
Encoding unicode = Encoding.UTF8;
Encoding ascii = Encoding.Default;
retVal = ascii.GetString(Encoding.Convert(unicode, ascii, unicode.GetBytes(text)));
// Set the return Value
retVal = text.Replace(Convert.ToChar(8217), '"');
}
catch
{
}
return (retVal);
}
If these two issues could be solved rather soon, I’d think about licensing Aspose.Report Corporate as we might also require Aspose.Pdf rather soon and would also extend our extsing Aspose.Excel license
Any help would be highly appreciated
Regards
Kai Iske
DWS Holding & Services