We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Word fields in convertions (RTF to DOC) not appears

Hi everyone!,

I'm novice with Aspose components in .NET plattaform (with c#). I don´t know how can i do this:

I need convert RTF files to DOC files. This works ok, but i have a problem: Why the content of word fields not appears?. I just read in FAQs that Aspose.Words supports word fields.

My code is this:

Aspose.Words.Document doc = new Aspose.Words.Document(_FileName);

doc.Save(_FileNameAs, Aspose.Words.SaveFormat.Doc);

This where the mistake?

Thanks alls.

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. There are no mistakes in your code. Could you please attach your documents here for testing? I will check the issue on my side and provide you more information.

Best regards.

Here you are the files:

file_to_convert.rtf

file_converted.doc

As you can see the .RTF file has 4 fields (very simples, no calculated), the fields are in .DOC file too but the content (result) not.

If i do the conversion with an Application and Word objects, the conversion is OK.

¿What can i do?

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I cannot reproduce the problem on my side using the latest version of Aspose.Words (8.1.0). You can download this version from here:

http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/category1188.aspx

Best regards,

Hi again,

I tried with 8.1.0 version and i have the same problem.

If you open (with MSWORD) the file "file_to_convert.rtf" you can see...: (i mark in red the fields)

"Dada cuenta; Por necesidades del servicio se suspende el señalamiento para el día 11 de febrero de 2010, y se señala nuevamente para la celebración de la Audiencia previa, el día 10 de febrero a las 11:15 horas."

But if you open (with MSWORD) the file of "file_converted.doc" you can read...:

Dada cuenta; Por necesidades del servicio se suspende el señalamiento para el día , y se señala nuevamente para , el día a las horas.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I tried to check the value of the result fields nodes (nodes between FieldSeparator and FieldEnd types) with Aspose.Words objects programmatically and i can found this values (exists). ¿Why MSWord not show them to me?. Is it possible that when open and save a document with Aspose.Words the references of result fields are missings?. What can i do? I am dessesperate.

Very thanks!!!!

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Please make sure that you use the latest version. To check version of the library, right click on the dll, select Properties from the context menu, then select Version tab. You will see File version.

In additional, could you please save your output document as DOCX and attach here for testing?

doc.Save("out.docx", SaveFormat.Docx);

I sent the document produced on my side to your e-mail

Best regards,

Hi Andrey,

Thanks for your email and your response.

I replace library for last version (8.1.0.0). I have the same problem. (i attach you the result file in docx format).

I just see your file conversion result and it´s OK. I don't know why i can not see word fields in my conversions. Could be a MSWORD configuration problem?. I tried it in some machines and i have the same problem in alls. Do you know if i need additional system configuration? I use Windows XP (with sp3) and MSOffice 2003 (with sp3).

I need an alternative solution while i resolve it. I thought to check the converted document (with aspose) and drop the word fields and replace it for results of that fields. What do you think? Can i do this with Aspose.Words and how do i? If you have a better idea i would be grateful for it to you.

Very thanks!!!

EDIT: i want to say with "drop" to delete the word fields and replace it for its result values. Then save the document again.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Do you perform some processing of the document or just convert it? Could you please create a simple application, which will allow me to reproduce the problem on my side?

No additional system configuration is required. Also, Aspose.Words is independent from MS Word, so its settings also cannot affect Aspose.Words.

Best regards,

Andrey, i will send you an example application in a few minutes. Thanks!

Andrey, i will send you in a few minutes an application example. Thanks!!!

Andrey i just created a new windows project only for testing convertion and works OK!.

I used VS2008 for it (the other project is in VS2005) but i don´t think this was the problem. I don´t understand it because the code to convertion is the same!.

I will investigate more... because this works!!!. If i will find what was the problem, i will tell you.

Thanks for all!!!

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you, I will wait for your inputs.

Best regards,

Andrey, i just found the problem!

Well, i have 2 RTF file types, : RTF1 - OK and RTF2 - NOK

The problem was in the RTF file. I discover that word fields in RTF1 are {ref HORA} and in RTF2 are {HORA}. I tried to modify in MSWORD the value of code field and works OK!.

Then, to resolve with Aspose i need open the RTF, check code fields nodes and if doesn´t start for "ref", add it. I try this code, please tell me if this is OK or not. Thanks!!!.

foreach (FieldStart start in starts)

{

if (start.FieldType == FieldType.FieldNone)

{

string fieldCode = string.Empty;

Node currentNode = start.NextSibling;

while (currentNode.NodeType != NodeType.FieldSeparator)

{

Node nextNode = currentNode.NextSibling;

if (currentNode.NodeType == NodeType.Run)

{

fieldCode += (currentNode as Run).Text;

if (!fieldCode.StartsWith("ref") || !fieldCode.StartsWith("REF"))

{

fieldCode = "ref " + fieldCode;

(currentNode as Run).Text = fieldCode;

}

}

currentNode = nextNode;

}

}

}

Hi!

The code i just posted works OK. I resolved the problem!.

I need open the file as RTF, check nodes, do what i write before and save as RTF. Then, open again and save as DOC.

Andrey very thanks for all and sorry for my english.

Best regards!.

Hi

It is perfect, that you already resolved the problem.

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Best regards,