How to make the first page in a section have different margins?

戏子无情 提交于 2019-12-25 08:11:25

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!