我无法弄清楚如何开始的页码时使用的OpenXML SDK 2.0节的特定点。这是我看到的时候我反省使用的OpenXML生产力工具在文档头部:
I can't figure out how to start the page numbering at a specific point for a section using OpenXML SDK 2.0. Here's what I see when I reflect on a header in a document using the OpenXML Productivity Tool:
<w:hdr xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 wp14">
<w:p w:rsidR="00FC0BC9" w:rsidP="00FC0BC9" w:rsidRDefault="005F46AD">
<w:pPr>
<w:pStyle w:val="Header" />
<w:ind w:right="360" />
<w:jc w:val="right" />
</w:pPr>
<w:r>
<w:t xml:space="preserve">I-1 Page </w:t>
</w:r>
<w:r>
<w:fldChar w:fldCharType="begin" />
</w:r>
<w:r>
<w:instrText xml:space="preserve"> PAGE \* Arabic \* MERGEFORMAT </w:instrText>
</w:r>
<w:r>
<w:fldChar w:fldCharType="separate" />
</w:r>
<w:r w:rsidR="00C62387">
<w:rPr>
<w:noProof />
</w:rPr>
<w:t>1</w:t>
</w:r>
<w:r>
<w:fldChar w:fldCharType="end" />
</w:r>
</w:p>
它看起来像它的建筑领域使用一组试验中,然后通过包括与1的文本价值Run启动的页码为这个头1 - 我应该指出,使用本节标题是第4页。
It looks like it's building the field using a set of Runs, and then by including a Run with a Text value of "1" to start the page numbering for this header to 1 -- I should mention the section that uses this header is on page 4.
不过,使用下面的code为自己的文档时,甚至当我产生相当于Word中坚持起始页码在当前页面。例如,第4页开始编号第4页中,当所需的行为是,第4页开始编号为第1页。
However, when even when I generate the equivalent using the following code for my own document, Word insists on starting the page numbering at the current page. For example, page 4 starts numbering at page 4, when the desired behavior is that page 4 starts numbering at page 1.
var headerPart = mainDocument.AddNewPart<HeaderPart>(GetHeaderIDFor(actWithScenes.Act, scene));
var header = new Header();
headerPart.Header = header;
header.Append(new Paragraph(
new ParagraphProperties(new Justification { Val = JustificationValues.Right }),
new Run(new Text(staticText) { Space = SpaceProcessingModeValues.Preserve }),
new Run(new FieldChar { FieldCharType = FieldCharValues.Begin }),
new Run(new FieldCode { Space = SpaceProcessingModeValues.Preserve, Text = " PAGE \\* Arabic \\* MERGEFORMAT " }),
new Run(new FieldChar { FieldCharType = FieldCharValues.Separate }),
new Run(new RunProperties(new NoProof()), new Text("1")),
new Run(new FieldChar { FieldCharType = FieldCharValues.End })
));
和这里的code其中我加入一个分节符,它的还是的不重启页次:
And here's the code where I'm adding a section break, which still doesn't restart the page numbering:
public static Paragraph AppendSectionBreak(Body body, string headerID = null, string footerID = null) {
var sectionProperties = new SectionProperties();
if (null != headerID) {
sectionProperties.Append(new HeaderReference { Id = headerID });
}
if (null != footerID) {
sectionProperties.Append(new FooterReference { Id = footerID });
}
var paragraph = new Paragraph(new ParagraphProperties(sectionProperties));
body.Append(paragraph);
return paragraph;
}
那么,我该如何开始的页码的部分标题为任意值?我失去了一些东西?
So, how do I start the page numbering for a section header at an arbitrary value? Am I missing something?
我想通了这一点最后。诀窍是使用下面的code:
I figured this out finally. The trick is to use the following code:
string headerID = "YOUR_HEADER_ID";
int pageNumberStart = 1
var paragraph = new Paragraph(
new ParagraphProperties(
new SectionProperties(
new HeaderReference { Id = headerID },
new PageNumberType { Start = pageNumberStart }
)
)
);
上一篇:跨code /视频转换的MP4在Android视频转换、code、Android
下一篇:对于通过JavaScript的应用程序打开谷歌游戏详情页面Android浏览器重定向应用程序、重定向、浏览器、详情