在离子应用程序中使用iframe标记

问题描述 投票:0回答:1

我正在开发一个简单的离子应用程序,我需要在应用程序的特定页面中插入和查看pdf。

我用这种方式使用了html <iframe>标签:

<iframe width="400" height="600" src="assets/documents/relation.pdf">
</iframe>

但它不起作用(pdf在页面内不可见)。

如果您使用<object><embed>标签,也会发生同样的情况。

谁能告诉我为什么?

非常感谢!

html pdf ionic-framework iframe
1个回答
0
投票
install cordova plugin add org.apache.cordova.inappbrowser In case of android we use GoogleDocs to open pdf file as by default android browser does not support pdf viewing. iOS is smart enough to handle pdf itself as usual smile .

Example :

$scope.view_link = function (url, link_type) {
            if (ionic.Platform.isAndroid()) {
                if (link_type !== undefined && link_type !== null) {
                    if (link_type.toLowerCase() !== 'html') {
                        url = 'https://docs.google.com/viewer?url=' + encodeURIComponent(url);
                    }
                }
            }
            var ref = window.open(url, '_blank', 'location=no');
        }
for more https://github.com/apache/cordova-plugin-inappbrowser/blob/8ce6b497fa803936784629187e9c66ebaddfbe1b/doc/index.md

if you are looking for iframe try something like this

<iframe ng-src="{{pdfurl}}" style="width:100%; height: 100%;"></iframe>
in controller..

$scope.pdfurl =$sce.trustAsResourceUrl('https://docs.google.com/viewer?url=' + encodeURIComponent($scope.pdf));
© www.soinside.com 2019 - 2024. All rights reserved.