You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm trying to set the starting number of page number in each sections by setting the ooxml ( because the api seems not support this function)
`const customizePageNumbering = async () => {
try{
await Word.run(async (context) => {
let docXML = context.document.body.getOoxml();
await context.sync();
let parser = new DOMParser();
let xmlDoc = parser.parseFromString(docXML.value, "text/xml");
const ns = {'w': 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'};
let sections = xmlDoc.getElementsByTagNameNS(ns.w, "sectPr");
if(sections.length > 1){
let firstSection = sections[0];
let pgNumType = firstSection.getElementsByTagNameNS(ns.w, 'pgNumType');
if(pgNumType.length === 0){
pgNumType = xmlDoc.createElementNS(ns.w, 'w:pgNumType');
pgNumType.setAttribute('w:start', '30');
console.log(pgNumType)
firstSection.appendChild(pgNumType);
console.log("after: ", firstSection);
console.log("Added pgNumType to first section");
}
else{
console.log("pgNumType already exists");
console.log(pgNumType.item(0));
}
let serializer = new XMLSerializer();
let modifiedXML = serializer.serializeToString(xmlDoc);
context.document.body.clear();
context.document.body.insertOoxml(modifiedXML, Word.InsertLocation.replace);
await context.sync();
}
});
}
catch (err) {
console.error(err);
}
}`
here is my code, in this example, I'm trying to set the page number of the first section start from 30, but it seems that I have already insert the <w:pgNumType w:start="30"/> in to the modifiedXML, but after I tried to insert the modifiedxml into the body, the pgNumType is deleted automatically, because when I checked the ooxml again, there is no pgNumType in the inserted xml, why is this happening? the code before the insertOoxml works just fine (I have loged the result and I'm sure about that)
The text was updated successfully, but these errors were encountered:
Hi, I'm trying to set the starting number of page number in each sections by setting the ooxml ( because the api seems not support this function)
`const customizePageNumbering = async () => {
try{
await Word.run(async (context) => {
let docXML = context.document.body.getOoxml();
await context.sync();
here is my code, in this example, I'm trying to set the page number of the first section start from 30, but it seems that I have already insert the <w:pgNumType w:start="30"/> in to the modifiedXML, but after I tried to insert the modifiedxml into the body, the pgNumType is deleted automatically, because when I checked the ooxml again, there is no pgNumType in the inserted xml, why is this happening? the code before the insertOoxml works just fine (I have loged the result and I'm sure about that)
The text was updated successfully, but these errors were encountered: