[英]Local PDF hyperlinks in Windows UWP app
我正在用JavaScript编写UWP应用。
其中包含一个链接列表,每个链接都称为PDF。
PDF会本地存储在应用程序中。
目的是为Hololens(Windows AR)提供免提文档库
无论如何,我通过以下方式打开PDF:
Windows.System.Launcher.launchFileAsync(file)
这一切都很好。
但是,PDF也通过超链接相互引用。
我可以将超链接修改为最初生成PDF时的任何形式。
但是,我如何做到这一点,以便在用户的默认PDF应用程序中打开时,超链接仍然可以相互引用。
同样,默认的PDF应用可以是任何东西。
在Windows的Adobe Acobat中,这可以正常工作,
希望将此功能移植到UWP。
当前代码和工作方式:
window.onload = function () {
document.getElementById("#id").onclick = function (evt) {
pdfopen("pdf.pdf")
}
function pdfopen(pdf) {
var imageFile = "assets\\" + pdf;
// Get the image file from the package's image directory
Windows.ApplicationModel.Package.current.installedLocation.getFileAsync(imageFile).then(
function (file) {
// Launch the retrieved file using the default app
var options = new Windows.System.LauncherOptions();
Windows.System.Launcher.launchFileAsync(file)
}
);
提前感谢任何帮助<3
但是,我如何做到这一点,以便在用户的默认PDF应用程序中打开时,超链接仍然可以相互引用。
当您使用没有LauncherOptions
的launchFileAsync
方法时,它将始终使用默认应用程序打开.pdf文件。
如果您设置始终使用应用程序打开.pdf文件,则应该能够使用LauncherOptions.TargetApplicationPackageFamilyName
设置用于启动文件的目标软件包的软件包系列名称。 然后,您可以在LaunchFileAsync(IStorageFile, LauncherOptions)
中添加LauncherOptions
,以使用指定的选项启动与指定文件关联的默认应用程序。
例如,使用Edge打开.pdf文件:
var options = new Windows.System.LauncherOptions();
options.TargetApplicationPackageFamilyName = "Microsoft.MicrosoftEdge_8wekyb3d8bbwe";
Windows.System.Launcher.launchFileAsync(file, options).then(
function(success) {
if (success)
{
// File launched
}
else
{
// File launch failed
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.