Adobe PDF嵌入API无法更改PDF(返回)

发布于 2025-02-02 22:13:40 字数 1355 浏览 2 评论 0原文

我的问题几乎与“ Adob​​e PDF嵌入API”中的线程中的问题几乎相同。这两者都是由雷蒙德·卡姆登(Raymond Camden)先生讲话的。唯一的区别是我试图将URL传递到位置:烧瓶的URL。这是代码:

if(window.AdobeDC) displayPDF(urldata);
else document.addEventListener("adobe_dc_view_sdk.ready", 
    () => displayPDF(urldata));

function displayPDF(urldata) {
    
    document.writeln(urldata[0]);
    document.writeln(urldata[1]);
    var myURL = urldata[0];
    var myFileName = urldata[1];
    adobeDCView.previewFile({
        content: {
            location: {
                url: myURL,
            },
        },
        metaData: {
            fileName: myFileName
        }
    }, viewerConfig);
} 

请注意,我正在使用Camden 技巧用于处理

调味良好的鸡肉和漂亮的新鲜鸡蛋

。 我可以将我的两个参数转到HTML文件和JS文件。它们都是从displayPDF(urldata)函数在页面上写入的。不幸的是,他们没有达到内容:位置:URL和元数据:文件名。如果我使用现有的PDF URL和文件名进行硬码这两个参数,我将获得我想要获得的结果。

我在做什么错?

感谢任何能给我一个线索的人。

最好的

Pierre-Emmanuel Fega

I have almost the same problem that in thread "Adobe PDF Embed API can not change the pdf" and "How to use a variable in Adobe's pdf embed API as URL-value?". which both were addressed by Mr Raymond Camden. The only difference is that I am trying to pass an url to location:url from Flask. Here's the code:

if(window.AdobeDC) displayPDF(urldata);
else document.addEventListener("adobe_dc_view_sdk.ready", 
    () => displayPDF(urldata));

function displayPDF(urldata) {
    
    document.writeln(urldata[0]);
    document.writeln(urldata[1]);
    var myURL = urldata[0];
    var myFileName = urldata[1];
    adobeDCView.previewFile({
        content: {
            location: {
                url: myURL,
            },
        },
        metaData: {
            fileName: myFileName
        }
    }, viewerConfig);
} 

Note that I am using Mr Camden trick for dealing with

well-seasoned chicken and nice fresh eggs

.
I can get my 2 parameters going to the html file and to the js file. They are both writelined on the page from the displayPDF(urldata) function. Unfortunately they don't make it to content:location:url and metadata:filename. If I do hardcode these two parameters with existing PDF url and filename I get the result I want to obtain.

What am I doing wrong?

Thanks to anybody who could give me a clue.

All the best,

Pierre-Emmanuel FEGA
[email protected]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拥抱没勇气 2025-02-09 22:13:40

我找到了自己问题的答案。我之所以将其发布在Adobe社区论坛上,是因为“从外部功能到文档功能的价值”,因为Shubhanshu Dixit和Raymond Camden的响应都对我有很大帮助。

我的目标是打开来自Azure Blob存储的PDF文件,以在Azure Web应用中使用它。该应用在烧瓶中。这是我完成的方式,它在Azure和本地都很好地工作:

烧瓶路线

@app.route("/document", methods=['GET', 'POST'])
def document():   
# Microsoft blob storage SAS token creation for accessing PDF file in blob storage
  blob = get_blob_sas(BLOB_NAME_PATH, STORAGE_ACCOUNT_KEY, BLOB_CONTAINER_NAME, document_to_retrieve)   
  blob_url = 'https://'+BLOB_NAME_PATH+'.blob.core.windows.net/'+BLOB_CONTAINER_NAME+'/'+document_to_retrieve+'?'+blob
# URL and Filename parameters to send to Adobe Embed API    
  urldata = [blob_url, document_to_retrieve]
return render_template('view.html', title='SYSTRA Semantic Selected Document', urldata=urldata)

html页面

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1"/>

    <script type="text/javascript" src="{{ url_for('static', filename='view.js') }}"></script>
    <script type="text/javascript">
        varPDF = previewFile({{urldata|tojson}})
    </script>
</head>
<body style="margin: 0px">

    <div id="adobe-dc-view"></div>
    <script type="text/javascript" src="https://documentcloud.adobe.com/view-sdk/main.js"></script>
</body>
</html>

javascript函数

function previewFile(urldata) {

    var myURL = urldata[0];
    var myFileName = urldata[1];

    if(window.AdobeDC) displayPDF(myURL, myFileName);
    else document.addEventListener("adobe_dc_view_sdk.ready", 
        () => displayPDF(myURL, myFileName));
}

function displayPDF(myURL, myFileName) {

    document.write('displayPDF');
    const viewerConfig = {
        embedMode: "FULL_WINDOW",
        defaultViewMode: "FIT_PAGE",    
        showLeftHandPanel: true,
        showAnnotationTools: true,
        showDownloadPDF: true,
        showPrintPDF: true,
        showPageControls: true,
        showDisabledSaveButton: true,
        downloadWithCredentials: true
    };

    var adobeDCView = new AdobeDC.View({
        clientId: '<CLIENT_ID_KEY_HERE',
        divId: "adobe-dc-view"
    });

    adobeDCView.previewFile({
        content: {
            location: {
                url: myURL,
            },
        },
        metaData: {
            fileName: myFileName
        }
    }, viewerConfig);
}

我希望这会有所帮助。

一切顺利,
皮埃尔·埃曼纽尔(Pierre-Emmanuel)

I've found an answer to my own question. I have posted it on Adobe Community forum as well because "Passing value from external function to document function" because both responses from Shubhanshu Dixit and Raymond Camden have been of great help to me.

My goal was to open a PDF file coming from Azure Blob Storage to use it in an Azure Web App. The app is in Flask. Here's how I've done it and it works great on Azure as well as locally:

FLASK ROUTE

@app.route("/document", methods=['GET', 'POST'])
def document():   
# Microsoft blob storage SAS token creation for accessing PDF file in blob storage
  blob = get_blob_sas(BLOB_NAME_PATH, STORAGE_ACCOUNT_KEY, BLOB_CONTAINER_NAME, document_to_retrieve)   
  blob_url = 'https://'+BLOB_NAME_PATH+'.blob.core.windows.net/'+BLOB_CONTAINER_NAME+'/'+document_to_retrieve+'?'+blob
# URL and Filename parameters to send to Adobe Embed API    
  urldata = [blob_url, document_to_retrieve]
return render_template('view.html', title='SYSTRA Semantic Selected Document', urldata=urldata)

HTML PAGE

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1"/>

    <script type="text/javascript" src="{{ url_for('static', filename='view.js') }}"></script>
    <script type="text/javascript">
        varPDF = previewFile({{urldata|tojson}})
    </script>
</head>
<body style="margin: 0px">

    <div id="adobe-dc-view"></div>
    <script type="text/javascript" src="https://documentcloud.adobe.com/view-sdk/main.js"></script>
</body>
</html>

JAVASCRIPT FUNCTIONS

function previewFile(urldata) {

    var myURL = urldata[0];
    var myFileName = urldata[1];

    if(window.AdobeDC) displayPDF(myURL, myFileName);
    else document.addEventListener("adobe_dc_view_sdk.ready", 
        () => displayPDF(myURL, myFileName));
}

function displayPDF(myURL, myFileName) {

    document.write('displayPDF');
    const viewerConfig = {
        embedMode: "FULL_WINDOW",
        defaultViewMode: "FIT_PAGE",    
        showLeftHandPanel: true,
        showAnnotationTools: true,
        showDownloadPDF: true,
        showPrintPDF: true,
        showPageControls: true,
        showDisabledSaveButton: true,
        downloadWithCredentials: true
    };

    var adobeDCView = new AdobeDC.View({
        clientId: '<CLIENT_ID_KEY_HERE',
        divId: "adobe-dc-view"
    });

    adobeDCView.previewFile({
        content: {
            location: {
                url: myURL,
            },
        },
        metaData: {
            fileName: myFileName
        }
    }, viewerConfig);
}

I hope this helps.

All the best,
Pierre-Emmanuel

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文