适用于pdf的Titanium Android模块



有人找到在Android上打开或查看PDF文件的方法吗

Titanium中是否有任何模块可以在Android应用程序中打开PDF文件。

您可以使用and Intent在最终用户pdf阅读器中打开它,但如果您需要在应用程序中打开它可以使用此库:https://marketplace.appcelerator.com/apps/6897?restoreSearch=true#!概述

意图:

    try {
var f = Ti.Filesystem.getFile('your.pdf');
Ti.Android.currentActivity.startActivity(Ti.Android.createIntent({
    action: Ti.Android.ACTION_VIEW,
    type: 'application/pdf',
    data: f.getNativePath()
}));
}
    catch (err) {
var alertDialog = Titanium.UI.createAlertDialog({
    title: 'No PDF Viewer',
    message: 'We tried to open a PDF but failed. Do you want to search the marketplace for a PDF viewer?',
    buttonNames: ['Yes','No'],
    cancel: 1
});
alertDialog.show();
alertDialog.addEventListener('click', function(evt) {
    if (evt.index == 0) {
        Ti.Platform.openURL('http://search?q=pdf');
    }
});

}