OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
670 stars 96 forks source link

This problem still exists, I set the line spacing to 30 points through code, but it shows up as multi-block 2.5 on word. In fact, the fixed value of 30 points and multi-line spacing 2.5 do not look consistent. #3203

Closed Axios1027 closed 5 months ago

Axios1027 commented 1 year ago

Message from office-js bot: We’re closing this issue because it has been inactive for a long time. We’re doing this to keep the issues list manageable and useful for everyone. If this issue is still relevant for you, please create a new issue. Thank you for your understanding and continued feedback.

          This problem still exists, I set the line spacing to 30 points through code, but it shows up as multi-block 2.5 on word. In fact, the fixed value of 30 points and multi-line spacing 2.5 do not look consistent.

image image

Originally posted by @Axios1027 in https://github.com/OfficeDev/office-js/issues/2296#issuecomment-1459757117

alison-mk commented 1 year ago

Hi @Axios1027, thank you for submitting an issue. So that we can help resolve this issue, can you use our bug report template and provide the following information?

Provide required information needed to triage your issue

Your Environment

Expected behavior

Current behavior

Steps to reproduce




Link to live example(s)




Provide additional details




Context

Useful logs

Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.

Axios1027 commented 1 year ago

Your Environment

Expected behavior

image

Current behavior

image

Steps to reproduce

  1. follow this tutorial:https://learn.microsoft.com/zh-cn/office/dev/add-ins/tutorials/word-tutorial?view=word-js-preview
  2. run this code: `async function applyHeaderStyle() { await Word.run(async (context) => {

    const doc = context.document; const selecttext = doc.getSelection(); selecttext.font.name = "FZXiaoBiaoSong-B05S"; selecttext.font.size = 22; const selectparagraph = selecttext.paragraphs.getFirst() selectparagraph.alignment = "Centered" selectparagraph.spaceBefore = 0 selectparagraph.spaceAfter = 0 selectparagraph.lineSpacing = 30

    await context.sync(); }) .catch(function (error) { console.log("Error: " + error); if (error instanceof OfficeExtension.Error) { console.log("Debug info: " + JSON.stringify(error.debugInfo)); } }); }`

Link to live example(s)

Provide additional details

  1. I tested the same situation on Windows

Context

Useful logs

alison-mk commented 1 year ago

Hi @Axios1027, thank you for for the information. I've assigned this issue to the engineering team who will be able to provide you with more information or help resolve the issue.

Cheers, Alison

wangyun-microsoft commented 1 year ago

@jipyua Can you please take a look at this one? Thanks.

jipyua commented 1 year ago

hi @Axios1027 for the paragraph.lineSpacing api, the documentation says: "Gets or sets the line spacing, in points, for the specified paragraph. In the Word UI, this value is divided by 12." So setting it to 30 points means what UI shows 30/12= 2.5 lines.

You can try from UI to set the same formatting text/paragraph to 2.5 lines or 30 pts, you will find they are the same.

Axios1027 commented 1 year ago

hi @Axios1027 for the paragraph.lineSpacing api, the documentation says: "Gets or sets the line spacing, in points, for the specified paragraph. In the Word UI, this value is divided by 12." So setting it to 30 points means what UI shows 30/12= 2.5 lines.

You can try from UI to set the same formatting text/paragraph to 2.5 lines or 30 pts, you will find they are the same.

Hello, I understand the conversion rules for this line spacing, but as can be clearly seen from the screenshot above me, the styles of multiple line spacing 2.5 and fixed value 30 pounds are completely different. The fixed value set through API will always be automatically converted to multiple line spacing in the UI, which is not feasible for documents with specific requirements for line spacing.

jipyua commented 1 year ago

I am using an English version Word and from UI no matter whether I set it to 2.5 lines or 30 pts, the paragraph spacing looks the same. BTW, the "line spacing" means the spacing between lines, would you please try some paragraphs with multiple lines and confirm whether the line spacing are the same? Also would you please prepare a document in your environment and share it to me so that I can confirm what's the cause?

Axios1027 commented 1 year ago

multiple line spacing 2.5 It should be very obvious from the screenshot that the display of the two types of line spacing in Word UI is different, while the js-api always automatically converts line spacing to multiple line spacing. I searched for information and found that it can be done with vba's api. image

jipyua commented 1 year ago

thanks for reporting this, I can reproduce it now, if the font is larger then it's more obvious. we have opened an internal item 7826968 to track this, but unfortunately, I have no detailed timeline for when this can be fixed. thanks.