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

Free Support Forum - aspose.com

Carriage return doesn't work in this table!?

Hello!
I use a template with many placeholders inside. These placeholders will be replaced by fixed strings:

A placeholder inside the template:
<<EXTERN(1077)>>

It will be replaced by following String:

Springer: Ulrike Oppenhaeuser\r
Instrumentierende/r: Andrea Seifert\r
Leitender Operateur: Michael Wiedmann\r
Assistent: Dr. Wassillios Papakonstantinou\r
Assistent: Dr. Wilfried Fischer\r
Assistent: Dr. Wassillios Papakonstantinou\r
Assistent: Dr. Wolfgang Stollhof\r
Anästhesist: Igor Fabricius\r
Anästhesie Funktionsdienst: Willi Bresgen\r
Anästhesie Funktionsdienst: Uschi Lorscheider\r
Anästhesie Funktionsdienst: Andrea Hoerstel

I have to use \r, because i’m using different plattforms(Linux, Windows, both at 32bit and 64bit).

Everything works well … Yesterday I found a
slightly larger
problem. A customer designed a template with some special tables. The placeholders were inside the tables. But the carriage return didn’t worked here!
All I got were squares instead of carriage returns…

I modified the template to find the problem. I placed the placeholder into the normal textand created a new table and placed the placeholde into it too. And thats the result:
-placeholder in customer table: no carriage returns…
-placeholder in normal text: carriage returns!
-placeholder in my own table: carriage returns!

After this test, i looked at the structure of the word template with the aspose document explorer. I never saw a table like this customer table…

Could someone perhaps take a look at the problem and help me? That would be
very nice!

Thanks,
hsp

PS:
The template and the resulting document are at the attachment.
The relevant placeholder is placeholder <<EXTERN(1077)>>.

I fixed the problem! At least I created a work around, but i don’t know why the problem occured…
If I insert a PARAGRAPH BREAK behind the placeholder, the carriage return will be parsed as a PARAGRAPH BREAK. If there is no PARAGRAPH BREAK behind the placeholder, the carriage return will be parsed as square…
Any ideas?

Hi

Thanks for your request and additional information. I cannot reproduce the problem on my side using the latest version of Aspose.Words for Java 4.0.2, and the following code:

// Open template
Document doc = new Document("C:\\Temp\\template.doc");
// Calling Replace
doc.getRange().replace(Pattern.compile("\\<\\\\>"), new MyReplaceEvaluator(), false);
doc.save("C:\\Temp\\out.doc");
public static class MyReplaceEvaluator implements ReplaceEvaluator
{
    public int replace(Object object, ReplaceEvaluatorArgs e) throws Exception
    {
        // Create new DocumentBuilder
        DocumentBuilder builder = new DocumentBuilder((Document) e.getMatchNode().getDocument());
        // Move cursor to the placeholder
        builder.moveTo(e.getMatchNode());
        // Insert content
        builder.writeln("Springer: Ulrike Oppenhaeuser\r Instrumentierende\r: Andrea Seifert\r Leitender Operateur: Michael Wiedmann\r Assistent: Dr. Wassillios Papakonstantinou\r Assistent: Dr. Wilfried Fischer\r Assistent: Dr. Wassillios Papakonstantinou\r Assistent: Dr. Wolfgang Stollhof\r Anästhesist: Igor Fabricius\r Anästhesie Funktionsdienst: Willi Bresgen\r Anästhesie Funktionsdienst: Uschi Lorscheider\r Anästhesie Funktionsdienst: Andrea Hoerstel");
        return ReplaceAction.REPLACE;
    }
}

I sent the document produced on my side to your e-mail.
Best regards,