Autodesk Forge Viewer v7:打开PDF

时间:2019-12-12 18:40:29

标签: autodesk-forge autodesk-viewer

我对Viewer v7有一些疑问,我在API参考参考教程中找不到任何答案。

我要做什么: 我想使用Forge Datamanagment API将PDF上传到Forge,然后通过查看器打开它

到目前为止,我已经做到了: 我设法将PDF文件上传到Forge并将其翻译为SVF。

但是,到目前为止,当我想使用查看器打开PDF时,我只会得到一个空白页面。我已遵循此tutorial,并另外添加了扩展名Autodesk.PDF。这就是我的代码:

Autodesk.Viewing.Initializer(options, () => {
   this.viewer = new Autodesk.Viewing.GuiViewer3D(this.viewerDiv);
   this.viewer.loadExtension("Autodesk.PDF").then(() => {
        const startedCode = this.viewer.start();
        if (startedCode > 0) {
            console.error('Failed to create a Viewer: WebGL not supported.');
            return;
        }
        Autodesk.Viewing.Document.load(urn, (doc) => this.onDocumentLoadSuccess(doc), (err) => this.onDocumentLoadFailure(err));
   });
});

onDocumentLoadSuccess(doc) {
   var defaultModel = doc.getRoot().getDefaultGeometry();
   this.viewer.loadDocumentNode(doc, defaultModel);
}

onDocumentLoadFailure(viewerErrorCode) {
   this.handleError('Error loading document', viewerErrorCode);
}

对于IFC文件,它可以正常工作,但不适用于PDF文件。

我看过一些使用loadModel函数的教程,该函数以URL作为输入来打开PDF文件,甚至不翻译它们。

这是我的问题:

  • 我什至需要翻译我的PDF文件才能在查看器中打开它?
  • 尽管成功转换为SVF,为什么Viewer不能用于IFC文件,而不能用于PDF文件?
  • 我是否可以将loadModel函数与URN一起使用(以base64结尾的objectId)?

预先感谢

1 个答案:

答案 0 :(得分:1)

第一季度:,我是否还需要翻译我的PDF文件才能在查看器中打开它?

A1 :是!根据Forge Viewer的使用条款,Autodesk Forge查看器只能用于查看由Autodesk Forge服务生成的文件

((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView();", new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("button.nsg-button"))));

第二季度:尽管成功转换为SVF,但Viewer为什么适用于IFC文件而不适用于PDF文件?

A2 :请提供来自GET:urn/manifest

的错误消息

第3季度:我是否也可以将loadModel函数与URN一起使用(以base64结尾的objectId)?

A3 :是的,如果我理解正确的话。以下是代码段和截屏视频:https://knowledge.autodesk.com/community/screencast/de6b2d2a-c6b3-4747-8664-bd79cf417765

/*!
 * LMV v7.6.1
 * 
 * Copyright 2019 Autodesk, Inc.
 * All rights reserved.
 * 
 * This computer source code and related instructions and comments are the
 * unpublished confidential and proprietary information of Autodesk, Inc.
 * and are protected under Federal copyright and state trade secret law.
 * They may not be disclosed to, copied or used by any third party without
 * the prior written consent of Autodesk, Inc.
 * 
 * Autodesk Forge Viewer Usage Limitations:
 * 
 * The Autodesk Forge viewer can only be used to view files generated by
 * Autodesk Forge services. The Autodesk Forge Viewer JavaScript must be
 * delivered from an Autodesk hosted URL.
 */