Skip to main content
Participant
May 11, 2022
Question

Uncaught (in promise) Error: getMetadata request failed

  • May 11, 2022
  • 2 replies
  • 1338 views

I'm using the Embedded PDF API to view/edit pdfs in my Blazor application.  I first tried using a link to the share point files but ran into what I beleive is permission issues.  I'm now trying to use a promise and getting the 'getMetadata request failed' error. Code snippets below. fileContents is a byte[]

 

window.ViewPDF = function (path, fileContent) {
//var adobeDCView = new AdobeDC.View({ clientId: "579a461bbf7e4daea9d6ea6b7e9684a2", divId: "adobe-dc-view" }); // tpud.org
var filePromise = Promise.resolve(byteToUint8Array(fileContent).buffer);
console.log(filePromise)
console.log(path)
var adobeDCView = new AdobeDC.View({ clientId: "68cd09d526f14c959632eb34b5dd0c3e", divId: "adobe-dc-view" }); // azurewebsites.net
adobeDCView.previewFile(
{
content: { promise: filePromise },
metaData: { fileName: path }
});
}

This topic has been closed for replies.

2 replies

Duane Pfeiffer
Participant
May 19, 2022

Raymond was correct.  Converting a byte[] array from c# into an Uint8Array does not produce a pdf.  I ended up converting the byte[] into a base64 string in c#, then converting that to a blob on the javascript side.

C#:

var base64String = Convert.ToBase64String(bytes);

 Javascript:

    const base64Data = await fetch(`data:application/pdf;base64,${base64String}`)
    const blob = await base64Data.blob()
    var filePromise = Promise.resolve(blob.arrayBuffer())
Raymond Camden
Community Manager
Community Manager
May 12, 2022

Are you sure the promise is returning PDF data and not something else?