Uncaught (in promise) Error: getMetadata request failed

New Here ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

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 }
});
}

TOPICS
PDF Embed API

Views

442

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
May 12, 2022 May 12, 2022

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 19, 2022 May 19, 2022

Copy link to clipboard

Copied

LATEST

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())

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

Make content for your business needs with Adobe Express.

Get started easily with free templates: