问题
I'm using PHP to create Word documents. I've figured out how to set the page margins for a section. I've also figured out how to set headers and footers for the first page, even pages and default pages of a section. What I can't figure out is how to set the top margin of a page different for the first page in a section.
Essentially, I have a larger header image on the first page of the section and need to push the top margin of that page down twice as far as the top margins on all the other pages of the section. Is this something that is possible? Knowing how to do it in the XML would be nice but it someone could simply tell me how to do it through the Word UI I could then go look at the resulting XML and figure it out.
回答1:
Margins are defined at the section level, i.e. if you want to have a page with different margins you need to create a new section for that page.
If, however, your goal is to insert an image in the first page header and move everything down, this can be done without an extra section (It goes without saying that you need to check the Different first page option, so that the image only appears on the first page of the respective section). All you have to do is to set the wrapping style of your picture to be inline with text, square, tight or top and bottom (i.e. any option that will reserve space for the image and not put the image behind or above text).
The easiest way is to create a sample Word document in Word with the desired formatting, and the use the document reflector that is included with the OpenXML SDK.
来源:https://stackoverflow.com/questions/39654569/how-to-make-the-first-page-in-a-section-have-different-margins