I’m trying to add a primary header to a document. It works fine
if the document is empty. If I add a couple sections to the
document before I add the header I get this exception on the last line of code below:
java.lang.IllegalArgumentException: Cannot insert a node of this type at this location.
Do I need to set anything special on the sections? Any idea why this only works for empty documents?
Here’s a code snippet:
DocumentBuilder builder = new DocumentBuilder(document);
Please mind that adding header/footer will fail if you already have the header/footer of this type in the section. In this case you need to either remove the already existing header/footer or copy header/footer child nodes to the existing header/footer one by one.
ClearHeadersFooters does not removes headers/footers from section, just clears their content. To remove all headers/footers from section use HeadersFooters.Clear(). To remove header/footer of the particular type use HeadersFooters[HeaderFooterType].Remove() . For example,
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.