Comments (7)
@Jayshiv1408Dev Please add details about what you mean when you say that the formatting is disturbed. It is a security risk to open a zip file, so I'm reluctant to do that. Could you add a screen shot of the disturbed formatting?
from office-js.
Expected Output PPT1
Error output PPT1
Expected output PPT2
![ExpectedOP PPT2](https://private-user-images.githubusercontent.com/133626379/330285952-42575bd4-3ebc-4f13-9b2d-e0f4ac177985.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTY1MDIwNzEsIm5iZiI6MTcxNjUwMTc3MSwicGF0aCI6Ii8xMzM2MjYzNzkvMzMwMjg1OTUyLTQyNTc1YmQ0LTNlYmMtNGYxMy05YjJkLWUwZjRhYzE3Nzk4NS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNTIzJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDUyM1QyMjAyNTFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zNjRmNzhjN2ZlYjEwNDAwMjVlZGQ4ODQxZmFkZGJkOTA4NmFkYWQ2ZTVjYjQ3YzdkNTU0Yjk0MDNjMmZhMDNjJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.CNrGURBaRsn55Mson_6mfv2rXSmciKtAXT0pVQc6rP4)
Here Formatting means Font style ,alignment font color and size is getting distrub.
Here is my source File For reference
PPT2.pptx
PPT3.pptx
PPT1.pptx
from office-js.
@Jayshiv1408Dev - Can you confirm how you're getting the original slides as base64? I think that may be the issue vs. the inserting part.
We recently released an api into preview that exports the slide as Base64. Can you try using that one to generate the Base 64 string?
from office-js.
@EsterBergen
When I open this original files normally in powerpoint it's look perfectly but when I open using base64 it's causing issue.
As per your guidance I have to exported its by using exportAsBase64() method and use that bytes to load slides?
Am I correct?
from office-js.
can you please provide CDN for preview. I use beta version CDN but its throw exception at exportAsBase64().
May be I'm doing something wrong.
Can you please provide some demo for this.
from office-js.
hi @Jayshiv1408Dev - As it's a preview API you'll need to refer to the Beta reference https://appsforoffice.microsoft.com/lib/beta/hosted/office.js
Try that and let us know if you still have an error.
Before using the preview API for exportAsBase64(), how were you converting your slides to base64?
from office-js.
Using C# File.ReadAllBytes("mypath"); I'm taking bytes from path and after that I'm using this code to convert byte into base64.
here my api response will pass in GetPPTDataSuccess(res)
function GetPPTDataSuccess(res) {
var Data = "";
if (res) {
Data = res[0];
if (Data != null) {
var bcontent = base64ToArrayBuffer(Data);
var blob = new Blob([bcontent], { type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' });
var file = new File([blob], 'test', { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
var fr = new FileReader();
fr.onload = ReplaceWordDocument;
fr.readAsDataURL(file);
ReplaceWordDocument(Data);
}
}
}
async function ReplaceWordDocument(data) {
if (this && this.result) {
var startIndex = -1;
var mybase64 = "";
data = this.result;
startIndex = data.indexOf("base64,");
mybase64 = data.substr(startIndex + 7, data.length);
if (officeview == "PowerPoint") {
await loadslide(mybase64);
}
}
}
async function loadslide(mybase64) {
try {
await PowerPoint.run(async (context) => {
context.presentation.load("slides");
await context.sync();
const slides = context.presentation.slides;
const slideCount = slides.getCount();
slides.load("items");
await context.sync();
slides.items.map((slide) => {
slide.delete();
});
await context.sync();
context.presentation.insertSlidesFromBase64(mybase64);
await context.sync();
Loader("hide", translate('Addin_J_302'), "S");
});
} catch (e) {
console.log("e", e);
}
}
from office-js.
Related Issues (20)
- getSelectedItemsAsync is not working properly in web browser HOT 2
- streaming asynchronous custom function failed to calculate time HOT 1
- Classic Outlook Windows ItemSend Add-in: Endless looping after updating manifest version HOT 8
- Excel Undo feature is not working after saving data in customXmlParts HOT 6
- Slow response times from AmURL in ID tokens for 365
- Mac Excel v16.85 crashes when opening workbooks modified by our add-on HOT 17
- #NAME issue for custom functions at random times on loading a workbook HOT 14
- Content add-ins for Powerpoint cannot export website inside an iframe in web version HOT 2
- The onMessageRecipientsChangedHandler event does not get executed completely in Mac HOT 4
- Menu option in Office Ribbon HOT 10
- Test: this issue is not a real issue, it's used for testing auto close ADO Flow
- Content Control `contentControlExited` event inconsistent across platforms HOT 4
- Question: Recommended approach to adding web pane to Excel worksheet via task pane HOT 7
- Excel Custom Function crashes when given 3 or more parameters HOT 4
- RibbonApi is no longer working HOT 24
- OnNewMessageCompose not working on desktop HOT 4
- Outlook add-in is not opening for some users in new Outlook for Windows UI HOT 4
- Office.initialize not invoked in Outlook Desktop app on Windows since May 22 2024 2PM PDT approximately HOT 1
- Result of parentControl.getContentControls() contains itself HOT 1
- Office.onReady does not resolve when using origin-trial token to turn off third-party matching on WebView2 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from office-js.