Overwritten page margin attributes

Home Forums WordprocessingML Overwritten page margin attributes

This topic contains 2 replies, has 2 voices, and was last updated by  poornima.binu@gmail.com 7 years, 10 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #3528

    I am trying to add a header to word document by inserting OOXML.And I am using the javacsript API for implementing the same.I set the page margin attributes inside the section properties.

    <w:sectPr w:rsidR=”00000000″>
    <w:pgMar w:top=”1440″ w:right=”1440″ w:bottom=”1440″ w:left=”1440″ w:header=”144″ w:footer=”144″ w:gutter=”0″/>
    </w:sectPr>

    For some reason word replaces these attribute values with new values(for header and footer).

    <w:sectPr w:rsidR=”00000000″>
    <w:pgMar w:top=”1440″ w:right=”1440″ w:bottom=”1440″ w:left=”1440″ w:header=”720″ w:footer=”720″ w:gutter=”0″/>
    </w:sectPr>

    Can I get some help on this?

    #3538

    Eric White
    Keymaster

    From your post, I understand that you write the page margins in the section props using the JavaScript API, and when you look at the file, it is as you generated it. But when you open and save the document using Word, it changes the values.

    You are specifying 144 for the values of the header and footer (which are very small values). If I recall correctly, there are circumstances where based on the printer metrics, Word will adjust values if the values are outside of the printable area for the printer.

    Can you check to see if this is the case?

    #3543

    Thank you for your reply.

    Basically I am not able to set any new value(big or small) to any of the page margin attributes .Please find the JS code written for the same.

    Word.run(function (context) {

    var body = context.document.body;

    body.insertOoxml(“<pkg:package xmlns:pkg=’http://schemas.microsoft.com/office/2006/xmlPackage’><pkg:part pkg:name=’/_rels/.rels’ pkg:contentType=’application/vnd.openxmlformats-package.relationships+xml’ pkg:padding=’512′><pkg:xmlData><Relationships xmlns=’http://schemas.openxmlformats.org/package/2006/relationships’><Relationship Id=’rId1′ Type=’http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument’ Target=’word/document.xml’/></Relationships></pkg:xmlData></pkg:part><pkg:part pkg:name=’/word/document.xml’ pkg:contentType=’application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml’><pkg:xmlData><w:document xmlns:w=’http://schemas.openxmlformats.org/wordprocessingml/2006/main’ ><w:body><w:p><w:pPr><w:rPr><w:color w:val=’70AD47′ w:themeColor=’accent6’/><w:sz w:val=’28’/></w:rPr></w:pPr><w:r><w:rPr><w:color w:val=’70AD47′ w:themeColor=’accent6’/><w:sz w:val=’28’/></w:rPr><w:t>Set the page Margins</w:t></w:r></w:p><w:sectPr w:rsidR=’00000000′><w:pgSz w:w=’12240′ w:h=’15840’/><w:pgMar w:top=’2880′ w:right=’2880′ w:bottom=’2880′ w:left=’2880′ w:header=’1440′ w:footer=’1440′ w:gutter=’0’/><w:cols w:space=’720’/></w:sectPr></w:body></w:document></pkg:xmlData></pkg:part></pkg:package>”, Word.InsertLocation.start);
    return context.sync().then(function () {
    });
    })
    .catch(function (error) {
    });

    I couldn’t see any change in the newly generated file.There is no change in values even after saving and opening it.The below page margin attributes are seen in the OOXML file for the newly generated word document.

    <w:pgMar w:top=”1440″ w:right=”1440″ w:bottom=”1440″ w:left=”1440″ w:header=”720″ w:footer=”720″ w:gutter=”0″/>

    I am not sure whether it is a limitation in JS API code.Is there any way to edit the word page setup values in javascript?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.