I use the Adobe PDF Embed API (https://www.adobe.io/apis/documentcloud/dcsdk/docs.html?view=view) to display pdfs within modals on a site of mine. As I want the modals to only change in one tiny detail (the file-url of the pdf displayed there) I wanted to use the filename dynamically. So I did that:
document.addEventListener("adobe_dc_view_sdk.ready", function() {
var adobeDCView = new AdobeDC.View({
clientId: "xyz",
divId: "adobe-dc-view"
});
adobeDCView.previewFile({
content: {
location: {
var model_filename_chosen = "https://www.URL.com/files/" +
var model_filename;
// Does get printed correctly
console.log(model_filename_chosen);
//doesn't get parsed at all
url: model_filename_chosen
}
},
metaData: {
fileName: "Something"
}
}, {
});
});
And that in the header before it
function openFahrzeugModal(data) {
x = new bootstrap.Modal(document.getElementById("modalFahrzeug"));
x.toggle();
$('#input_model_hidden').val(data);
var model_filename = data;
console.log(data);
}
And the trigger for those looks then something like that:
<a onclick="openFahrzeugModal('myfile1.pdf')">
So any log does get printed correctly but the pdf isn't shown at all, the modal opens up correctly. The variable does get printed in other elements of the modal correctly but within the Adobe embed-thing the result is empty. I do use the same domain for the code and the file and my API-key is valid. As soon as I enter a static URL (the same basically as the one that gets printed on the console) the pdf gets shown correctly.
Why is that and what would I need to fix?