Footnote and comments in header or footer

Hi support,

Please note that if you insert a footnote in the header or footer, you get error message when you try to save the document, and not in the try&catch block that inserts the footnote. Same happends for comments.

Here is my code for footnotes :

Document doc = null;
try
{
    doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);
    builder.moveToHeaderFooter(HeaderFooterType.HEADER_FIRST);
    builder.write("Header text");
    int footnoteType = FootnoteType.FOOTNOTE;
    builder.insertFootnote(footnoteType, "myFootnote");
}
catch (Exception e)
{
    // TODO Auto-generated catch block
    e.printStackTrace();
}
try
{
    doc.save("C:\Temp\TRS\docFootnoteCrash.doc");
}
catch (Exception e)
{
    // TODO Auto-generated catch block
    e.printStackTrace();
}

Is this expected behavior ?

Regards,
Milan

Hi
Thanks for your request. Yes, this is expected behavior. Do you think the exception should be thrown when you try to insert footnote or comment? I will consult with our developers and provide you more information regarding this issue.
Best regards.

Hi Alexey,

Yes, I think that any exception should be thrown when the wrong code handling is done, if possible, and not at the end. Thus, the exception can be handled, and the rest of the document can be saved. In the way the footnote and comment exceptions are handled now, all the document content is lost.

Anyway, I’ll use builder.getCurrentStory() to check the current container and avoid the crash.

(Just as a note : this case is related to IllegalStateException errors).

Best regards,
Milan