xcode 使用手机间隙打开pdf

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10481045/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:12:56  来源:igfitidea点击:

Open pdf using phone gap

javascriptxcodecordovapdf

提问by Sana Joseph

I wan't to open a pdf file on Xcode using phone gap[corodova 1.7.0]. Is it possible ? I can read text files, but for pdf should I use a plugin or something ? Thanks.

我不想使用电话间隙 [corodova 1.7.0] 在 Xcode 上打开 pdf 文件。是否可以 ?我可以阅读文本文件,但对于 pdf 我应该使用插件还是什么?谢谢。

回答by Mayur Birari

Why don't you try child browserplugin to view pdf in phonegap app.

为什么不尝试使用子浏览器插件在 phonegap 应用程序中查看 pdf。

function onDeviceReady() {

        var root = this;
        cb = window.plugins.childBrowser;

        if(cb != null) {
        cb.onLocationChange = function(loc){ root.locChanged(loc); };
        cb.onClose = function(){root.onCloseBrowser(); };
        cb.onOpenExternal = function(){root.onOpenExternal(); };
        cb.showWebPage("http://xyz.com/server/data/test.pdf");

        }
    }

    function onCloseBrowser() {
        console.log("onCloseBrowser!");
    }

    function locChanged(loc) {
        console.log("locChanged!");
    }

    function onOpenExternal() {
        alert("onOpenExternal!");
    }

回答by U?ur ?zp?nar

No need to useplugin rigth now(cordova 2.4+)

现在不需要使用插件rigth(cordova 2.4+)

IFRAMEis not a solution.

IFRAME不是解决方案。

OBJECT, EMBEDis not a solution.

OBJECT,EMBED不是解决方案。



Solution

解决方案

window.open('http://example.com/any.pdf', '_blank', 'location=no');

This code will open a child browser.

此代码将打开一个子浏览器。



Phonegap PDF Viewer pluginmade for local pdf files and It fails.

为本地 pdf 文件制作的Phonegap PDF 查看器插件失败了

回答by Samuli Hakoniemi

You can open PDF's directly within iframe element.

您可以直接在 iframe 元素中打开 PDF。

Another option which is worth of trying - pdf.js: https://github.com/mozilla/pdf.js

另一个值得尝试的选项 - pdf.js:https: //github.com/mozilla/pdf.js

回答by Mohit

Solution

解决方案

window.open("http://docs.google.com/viewer?url=" + pdflink +" ");

window.open(" http://docs.google.com/viewer?url=" + pdflink +" ");

This code will open the pdf in android phones

此代码将在 android 手机中打开 pdf

Before using this, First add phonegap.js to your HTML page

在使用这个之前,首先将 phonegap.js 添加到你的 HTML 页面

回答by jafarbtech

You could use pdf embedding using an iframewith the following url

您可以使用带有以下网址的iframe使用 pdf 嵌入

If your PDF URL is http://yourdomain.com/your_pdf_name.pdfthen you should use the following code

如果您的 PDF URL 是http://yourdomain.com/your_pdf_name.pdf那么您应该使用以下代码

<iframe src="https://docs.google.com/viewer?url=http://yourdomain.com/your_pdf_name.pdf&embedded=true"></iframe>

回答by Tom Cool

for local pdf files use:

对于本地 pdf 文件,请使用:

window.open('./any.pdf', '_blank', 'location=no');

window.open('./any.pdf', '_blank', 'location=no');