Formfields result limited to 255 characters


#1

Hi,

I have to read back information from a word document with aspose.word.
In the document the formfield contains text with a length greater then 255.

When I put data into the formfield with aspose.word it can be greater then 255, but when I try to read it from the formfield only 255 characters come back.

maybe I use the wrong way to read it :

dim aStr as string

aStr = oAD.Range.FormFields.Item(aIndex).Result

With regards,

Richard Bergmans
Ingenieursbureau van der Linden
The Netherlands


#2

Hi Richard,

I’ve checked and it works for me:

[Test]

public void TestFormFieldLongText()

{

Document doc = TestUtil.Open(@“Model\TestFormFieldLong.doc”);

string s = new string(‘A’, 300);

doc.Range.FormFields[0].Result = s;

doc = TestUtil.SaveOpen(doc, @“Model\TestFormFieldLong Out.doc”);

Assert.AreEqual(s, doc.Range.FormFields[0].Result);

}

Please check that your code does not truncate the string somewhere accidentally. If that does not help, send me a bigger code sample.


#3

Hi Roman,

That does work for me too, but…it is the other way around which doesn’t work.

Dim oAW As New Word
Dim oAD As Document = oAW.Open(“testdoc.doc”)
Dim aStr As String

aStr = oAD.Range.FormFields.Item(ffdIndex).Result

If the formfield contains 300 characters only 255 characters results in the aStr variable.

With regards,

Richard Bergmans


#4

How did you insert long text into the form field in the first place? Using Aspose.Word or MS Word? If you insert it in MS Word, maybe it is truncating to 255 chars? There is nothing in Aspose.Word to truncate the text and string length in the document is stored as 16bit integer.


#5

Hi Roman,

Sorry, I was searching in the wrong place indeed.
It’s getting truncated by MS Word before I read the document.

Regards,

Richard Bergmans