Word Web Add-in - Footer content alignment

Asked

Viewed 29 times

1

Hello!

I am developing an add-in for Word, following the template in visual studio.

Today, with the code to follow, I have the result almost finalized. However, in Footer, I can not in any way (of which I have tried and researched) align this blessed text on the right.

Also, as you can see, there is an image in the header, this image is not showing 100% wide because the page has a margin. I would like it to be 100% wide in Header. How could I?

Code:

Word.run(function (context) {
    var mySections = context.document.sections;

    context.load(mySections, 'body/style');

    return context.sync().then(function () {

        var myHeader = mySections.items[0].getHeader("primary");
        myHeader.clear();


        myHeader.insertInlinePictureFromBase64(imgHeader, Word.InsertLocation.start);
        myHeader.insertContentControl();


        var myFooter = mySections.items[0].getFooter("primary");
        myFooter.clear();

        myFooter.insertHtml("<p align='right'>São Paulo ∙ Brasília</p><p align='right'>www.google.com</p >", Word.InsertLocation.start);
        myFooter.insertContentControl();

        return context.sync().then(function () {
            console.log("Added a header for the first section.");
            console.log("Added a footer for the first section.");
        });

    });
})
    .catch(function (err) {
        console.log('Error: ' + JSON.stringify(err));
        if (error instanceof OfficeExtension.Error) {
            console.log("Debug Info: " + JSON.stringify(err.debugInfo()));
        }
    });

Image result:

Header generated with the above code

Header do Documento Word, gerado pelo fonte acima

  • 1

    Try putting a style instead of align: style="text-align: right"...

  • I had already tried this method. It has the same effect as the one I showed above.

  • 1

    You have to use the browser’s Dev Tools (F12) to see how these <p> are being displayed, if there is any CSS interfering etc..

  • So sam, the problem is that my VS already opens straight in the Word of my machine... This already standard, only in startar the application. There would be a way to configure to run on the web, I already try. It would be a really good output

  • 1

    Then I don’t know. :/

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.