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
686 stars 95 forks source link

MS Powerpoint Addin : Insert Slide from Base 64 Powerpoint addin API does not carry over the original formatting of the slide #2780

Closed Uttam-Gupta closed 7 months ago

Uttam-Gupta commented 2 years 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.

Provide required information needed to triage your issue

Your Environment

Expected behavior

In my application, I'm using the 'Insert Slide from Base 64' function in Powerpoint API. The slide inserted should use the same original formatting from the PPTX file (from which the base64 string is created)

PowerPoint.run(function (context) { return context.sync.then(function(){ context.presentation.insertSlidesFromBase64(base64String),{ formatting: 'KeepSourceFormatting' }; return context.sync() }) });

Current behavior

The content formatting which is present in the original PPTX file is not carried over when using the PowerPoint API.

Steps to reproduce

  1. Open Powerpoint - -Create new Presentation -Go to script lab - click on run
  2. Insert file that I've attached in this post
  3. click on 'Insert all Slides'
  4. Now open the file that I've attached in another window, you can see that the slides that were inserted using script lab and the original PPTX file. The formatting will be different.

Provide additional details

Context

I have an application, which stores a list of PPTX files in cloud, the user can select the file using the addin and insert all the slides from the PPTX file.

Useful logs

Lookup_addin_issue_file.pptx

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.

Uttam-Gupta commented 2 years ago

@JinghuiMS @ononder Any update on this issue? We have a lot of customers using this feature, so any kind of information on this issue would be highly helpful. Thanks.

JinghuiMS commented 2 years ago

From official document(https://docs.microsoft.com/en-us/office/dev/add-ins/powerpoint/insert-slides-into-presentation#insert-slides-with-insertslidesfrombase64), the inserted slides keep the formatting of the source file by default, otherwise, you can use below code to keep the formatting of the destination.

async function insertSlidesDestinationFormatting() {
  await PowerPoint.run(async function(context) {
    context.presentation
    .insertSlidesFromBase64(chosenFileBase64,
                            {
                                formatting: "UseDestinationTheme",
                                targetSlideId: "267#"
                            }
                          );
    await context.sync();
  });
}

@ononder What do you experts think about this issue?

Uttam-Gupta commented 2 years ago

@JinghuiMS Thanks for your input but the issue is that source formatting is not getting retained for the file I've attached.

JinghuiMS commented 2 years ago

@Uttam-Gupta If you don't specific to use "formatting: "UseDestinationTheme"", it should keep the formatting of source file by default.

Uttam-Gupta commented 2 years ago

@JinghuiMS The issue is that even if we are using the 'Source Formatting', the exact formatting doesn't seem to appear. We have used { formatting: 'KeepSourceFormatting' } but it's not working as expected for the file i've attached. The issue seems to appear only for certain files.

ononder commented 2 years ago

We need to investigate this more, one quick question on top of my head is, does this happen with a specific content on the given file or does it happen with all files? If it doesn't happen with all files, we should try to find the problematic content in that file.

Uttam-Gupta commented 2 years ago

@ononder I agree, but I'm not able to figure out the root cause in that particular file. I've attached the file in this post, can you please guide me on how I can help you? It doesn't happen with all files but in the powerpoint file I've attached, it seems to happen for all slides.

gmani1978 commented 2 years ago

@ononder @JinghuiMS Any luck in this, please? We are really requesting some help. Please let us know if any workaround