Skip to main content
Known Participant
Jul 31, 2020 3:01 AM UTC
Question

Embed API using base64 string of PDF

 

adobeDCView.previewFile({
      content: base64str,
      metaData:{fileName: "check.pdf"}
    },

 

I have not been successful in using the EmbedAPI when the PDF is a base64hex string. Does the content object of the Preview method support it. If so how? I tried some of the options but it gives content error

Thanks,

This topic is closed to new replies. Start a new post to keep the conversation going.

14 replies

Participant
Jul 28, 2021 10:10 AM UTC

I tried replicating this, but it does not load the viewer at all. Neither an I getting any errors or console logs. 
Am I doing something wrong?
The viewer was working perfectly for the URL
@Shubhanshu Dixit 
@Joel Geraci  - your codepen is not showing the viewer

 

var resp : {"content": "JVBERi0xLjMKJcTl8uXrp/Og0MTGCjQgMCBvYmoKPDwgL0xlbmd0aCA1IDAgUiAvRmlsdGVyIC9GbGF0ZURlY29kZSA+PgpzdHJlYW0KeAGtnOtv5MaRwL/PX8HLl5OANc3345AEcBwfcsZdgtgCcsBtPmhHs9bauzOyHnaMQ/....."
};

function base64ToArrayBuffer(base64) {
        var bin = window.atob(base64);
        var len = bin.length;
        var uInt8Array = new Uint8Array(len);
        for (var i = 0; i < len; i++) {
          uInt8Array[i] = bin.charCodeAt(i);
        }
        return uInt8Array.buffer;
}  

 var previewFilePromise = adobeDCView.previewFile(
       {
        content: { promise: Promise.resolve(base64ToArrayBuffer(resp.content)) },
          metaData: {fileName: "Bodea Brochure.pdf", id: "12345ghb"}
       }, {
         enableSearchAPIs:true,
       });

 

Translate
Joel Geraci
Community Expert
Community Expert
Jul 28, 2021 2:35 PM UTC

@vedika0101  - I'm seeing the viewer just fine in Chrome. What browser are you using? 

Translate
Joel Geraci
Community Expert
Community Expert
Jul 31, 2020 4:04 PM UTC

I've posted a working CodePen here.

Translate
R.M.RAuthor
Known Participant
Jul 31, 2020 4:26 PM UTC

Thanks Joel. That looks helpful. It's rather late this part of the world. I will give this a try in my web component tomorrow. 

Translate
Community Manager
Jul 31, 2020 11:04 AM UTC

No, PDF Embed APIs don't support base64 encoded PDF. Please find more information on Embed APIs here - https://www.adobe.io/apis/documentcloud/dcsdk/docs.html. You can however, open file in your application, convert from base 64 and pass converted blob to Embed APIs. Help documentation also describes how to pass file blob. 

Translate
R.M.RAuthor
Known Participant
Jul 31, 2020 11:13 AM UTC

Hello Brajesh:

 

Thanks for this. In fact, I am doing something similar but I seem stuck at understanding the content promise.

 

Here is what I am doing. I am reading the file (from a secure drive with auth) as a blob. I tried serving it as:

 

adobeDCView.previewFile({
 content: blob,
 metaData: { fileName: "test.pdf" }
 },
 {
   embedMode: "SIZED_CONTAINER"
 });

 

It gives a content error

Translate
R.M.RAuthor
Known Participant
Jul 31, 2020 11:18 AM UTC

I even tried

 

var filePromise = blob.arrayBuffer();
..
adobeDCView.previewFile({
  content: {promise: filePromise},
  metaData: { fileName: "test.pdf" }
}

This too brought up the adobe viewer with a content error

 

Translate
Participant
Jul 31, 2020 3:24 AM UTC
Can you please send me more information about this
Translate