[Adobe PDF Embed API] Cannot find variable error
adobe-pdf-embed-api
Reactive icon
Forge component by Matthew Matias
Application Type
Mobile
Service Studio Version
11.53.5 (Build 60717)
Platform Version
11.15.0 (Build 34858)

Hi,

I'm using the Adobe PDF Embed API forge asset linked above in a mobile app to load PDF's from binary data stored in a database.

I keep getting "Can't find variable: AdobeDC" error messages.

Android
|In Android, they occur rarely, and only after a new install or it's been a while since the app was opened. Once you exit the page and re-open the page, it loads fine and continues to do so from there on in.

iOS
Never works. Always gives the error message. Example of log entry at bottom of post.

Differential
The only references to the variable I can find is located in the module itself, under ViewPDFBinary -> GetClientIDOnAfterFetch  (Client action) -> Adobe Init (Javascript). It seems that this is where the variable AdobeDC is iniitalised.

Given that it sometimes errors in Android, and then works afterwards, it seems like the error is occuring because the module is running before the variable has had time to initialise perhaps?. But I'm not skilled in JS, so not sure if this is the case!

I would be very grateful for any direction or advice. 
Thank you



Example Error Log

Message

Can't find variable: AdobeDC

Environment Information

eSpaceVer: Id=4511, PubId=0, CompiledWith=11.15.0.34858RequestUrl: https://personal-4plka1hb.outsystemscloud.com/EDApp/moduleservices/log?clientTimeInMillis=1656487773234 (Method: POST)AppDomain: /LM/W3SVC/7/ROOT/EDApp-128-133009611337734372FilePath: C:\OutSystems\Sandboxes\JVJURE004\Platform Server\running\EDApp\ClientIp: 176.25.180.197DeviceUUID: 3DFF2E09-07C4-44AD-8A5C-C5B9EC435CDCLocale: en-USDateFormat: dd-MM-yyyyPID: 35476 ('w3wp', Started='6/28/2022 5:46:36 PM', Priv=843Mb, Virt=2116498Mb)TID: 135Thread Name:.NET: 4.0.30319.42000DeviceModel: iPhone13,2NativeShell: 11.2.1AppVersionCode: 193AppVersionName: 1.30.1Client Runtime Packages: client-runtime-core= 3.20.0;client-runtime-view-framework-react= 3.2.1;client-runtime-widgets= 3.4.0;DeviceUUID: 3DFF2E09-07C4-44AD-8A5C-C5B9EC435CDCNetworkStatus: OnlineCordova: 6.2.0NetworkType: wifiOperatingSystem: iOS 15.5Client-Side Log

Stack

loadAdobe@outsystems://personal-4plka1hb.outsystemscloud.com/EDApp/scripts/AdobePDFEmbedAPI.PDFViewer.ViewPDFBinary.mvc.js?oaG6oppDe6YpsXm7E3fmxg:561:38@outsystems://personal-4plka1hb.outsystemscloud.com/EDApp/scripts/AdobePDFEmbedAPI.PDFViewer.ViewPDFBinary.mvc.js?oaG6oppDe6YpsXm7E3fmxg:537:18@[native code]@outsystems://personal-4plka1hb.outsystemscloud.com/EDApp/scripts/OutSystems.js?eq9LGmzdgJbMq6dbNoVMvQ:16:7701@outsystems://personal-4plka1hb.outsystemscloud.com/EDApp/scripts/AdobePDFEmbedAPI.PDFViewer.ViewPDFBinary.mvc.js?oaG6oppDe6YpsXm7E3fmxg:390:29@outsystems://personal-4plka1hb.outsystemscloud.com/EDApp/scripts/AdobePDFEmbedAPI.PDFViewer.ViewPDFBinary.mvc.js?oaG6oppDe6YpsXm7E3fmxg:334:43promiseReactionJob@[native code]

Hi Leigh, 

Firstly, thanks for trying this out! I hadn't tried this in a mobile application but i will see if i can help.

It seems that the Init script is trying to load before the SDK JS has loaded, or maybe the SDK is not loading at all. You would need to make sure that the requireScript has executed before you run the Init. The AdobeDC module is loaded from the SDK, then the Init Script initialises the adobeDCView object ( var adobeDCView = new AdobeDC.View({....}) ).

If the app can't find the variable, AdobeDC then it's a problem with the SDK script

The SDK is Loaded in the OnReady Action of the web block. There is also a Client Action AddAdobeScript, perhaps you could make that public and run it in your application first. Alternatively you could add a RequireScript action in your page and use the SDK URL: "https://documentcloud.adobe.com/view-sdk/main.js"

Matt

Hi Matthew and thank you for taking the time to respond.

I think I understand that either the Init script is trying to load before the SDK JS has loaded, or that the SDK script is not loading at all. To try and resolve this, I have tried the following:

  1. Made the AdobePDFEmbedAPI->AddAdobeScript client action public. And then included it in an OnInitialize action for the page that contains the AdobePDFEmbedAPI web block. 

  2. I copied the SDK JS from the URL into a seperate script in the OS folder, and selected it under the Required Scripts section of the page that contains the AdobePDFEmbedAPI web block.

  3. Added the script as required under the app top level settings, so assume it should try and load it on app start.

  4. I've also de-activated all content security policies and external resource settings and re-generated the app.

The errors persist in iOS, although, I no longer seem to get the error on clean Android installs, which suggest that one or all three of the above have suceeded in ensuring that the SDK is loaded before the Init script.

I'm assuming that the SDK JS isn't executing at all on iOS, but nothing showing in any of my logs.

Where should I go from here?

Thank you


Hi.
I'm getting a bit closer... Not quite sure what I've done, but, the PDF now opens in iOS very briefly, before getting the error message 

"The application domain (outsystems://personal-3483432h(obfuscated).outsystemscloud.com) is not authorized to use the provided PDF Embed API Client ID"

I've checked the domain in my Adobe API and it includes everything except the outsystems:// prefix, which the adobe website prevents, unfortunately, stating it to be an invalid domain (understandable).

Unfortunately there doesn't appear to be any wildcards available, or way to get adobe to accept the domain with the forced outsystems// prefix.

Can anyone see a way round this, please?

This can't be isolated to this issue, but must affect any domain based authentication credentials, for other applications?

Thank you

For anyone stumbling onto this thread searching for their own answers...

I abandoned this plugin and couldn't find a way to open a PDF on iOS direct from a database as binary data.

Instead, once I'd retrieved the binary data using an aggregate, I used the File Plugin to save the binary to a pdf file locally, and then used the File Viewer Plugin to open it. It works lovely. Wish I'd have taken this approach from the start.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.