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

Free Support Forum - aspose.com

IllegalStateException errors

Hi support,

What is the straight and easiest way to avoid crashes in cases like : comments or footnotes in header&footer, page breaks or section breaks in table cells, etc, using Apose.Word for java ?

Please advice,
Milan

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

Thanks for your request.

1. You can use try catch statement to handle IllegalStateException exception. Something like the following:

try

{

builder.insertBreak(BreakType.PAGE_BREAK);

}

catch (java.lang.IllegalStateException ex)

{

//Do something.

}

2. You can check whether you can insert break at current position. For example:

if (builder.getCurrentParagraph().getParentNode().getNodeType() == NodeType.BODY)

{

builder.insertBreak(BreakType.PAGE_BREAK);

}

else

{

//Do something.

}

Hope this helps.

Best regards.