2

I've set up some templating functionality which modifies existing .docx files to insert custom values.

It worked for a while with the values I was interested in being contained within the files word/header1.xml and word/header2.xml

Now the code has stopped working and the values seem to be in word/header3.xml

How many headerX.xml files can there be, where X is a number? I don't know whether to alter my code to allow for an unlimited number (which is more of a pain) or whether there can be only, say, 5, or one per page, or some other limit.

4

1 に答える 1

4

Three (I think) per section, depending on whether you have different first page, odd/even.

You can have multiple sections..

You shouldn't rely on the number n being predictable in word/header*n*.xml, or even that headers/footers will have part names of that form.

The proper way is to look at the rels part for the main document part, and identify the header parts by their type.

For which header is used where and how, you need to look at the sectPr elements in the main document part.

于 2012-08-01T22:11:48.593 に答える