Hi,
I use Aspose.Words for Java, when I outputed string to MS Word, I found extra CR introduced between lines. You can check the difference between MS Word and Java Console.
“\r\n” and ‘\n’ should have some behavior in Java, you also can check below testing Java String tmp and tmp1, in Java Console, they are the same output, but in Aspose, they are not.
So I think it’s a defect of Aspose, please advise.
My testing codes:
import java.awt.Color;
import com.aspose.words.DocumentBuilder;
import com.aspose.words.LineStyle;
import com.aspose.words.Table;
public class TestCRIssue {
public static void main( String []argv ) throws Exception{
DocumentBuilder docBuilder = new DocumentBuilder();
docBuilder.clearRunAttrs();
String tmp = "line 1\r\nline 2 after one CR\r\n\r\nline 3 after two CRs\r\n\r\n\r\nline 4 after three CRs";
String tmp1 = "line 1\nline 2 after one CR\n\nline 3 after two CRs\n\n\nline 4 after three CRs";
docBuilder.writeln( tmp );
docBuilder.writeln( tmp1 );
System.out.println( tmp );
System.out.println( tmp1 );
docBuilder.getDocument().save( "C:\testCellSpacing.doc" );
// docBuilder.getDocument().updateTableLayout();
docBuilder.getDocument().save( "C:\testCellSpacing.pdf" );
}
}
Thanks,
Feng