gpt4 book ai didi

cordova - 在 Windows 8 中打开生成的 pdf

转载 作者:行者123 更新时间:2023-12-02 01:43:59 24 4
gpt4 key购买 nike

我正在使用 javascript 库 jsPDF 生成 pdf。我需要在 Windows 8 中打开生成的 pdf。使用 window.open 不起作用。我尝试保存文件并打开,但没有成功。

如何打开pdf?

[更新]

我正在尝试像这样使用 writeBufferAsync 保存它:

        var data = pdf.output('arraybuffer');

Windows.Storage.FileIO.writeBufferAsync(file, data).done(function () {
// Let Windows know that we're finished changing the file so the other app can update the remote version of the file.
// Completing updates may require Windows to ask for user input.
Windows.Storage.CachedFileManager.completeUpdatesAsync(file).done(function (updateStatus) {
if (updateStatus === Windows.Storage.Provider.FileUpdateStatus.complete) {
WinJS.log && WinJS.log("File " + file.name + " was saved.", "sample", "status");
} else {
WinJS.log && WinJS.log("File " + file.name + " couldn't be saved.", "sample", "status");
}
});
});

但我不断收到异常,我 writeBufferAsync 需要数字数组。数据类型为 ArrayBuffer。

[更新 2]

我尝试了以下方法,错误图像不显示:

var data = pdf.output();

Windows.Storage.FileIO.writeTextAsync(file, data).done(function () {
// Let Windows know that we're finished changing the file so the other app can update the remote version of the file.
// Completing updates may require Windows to ask for user input.
Windows.Storage.CachedFileManager.completeUpdatesAsync(file).done(function (updateStatus) {
if (updateStatus === Windows.Storage.Provider.FileUpdateStatus.complete) {
WinJS.log && WinJS.log("File " + file.name + " was saved.", "sample", "status");
} else {
WinJS.log && WinJS.log("File " + file.name + " couldn't be saved.", "sample", "status");
}
});
});

最佳答案

将PDF写入文件系统,使用window.open(fileURL, '_blank')打开。这就是你应该做的。您是如何尝试打开它的,打开时发生了什么?

关于cordova - 在 Windows 8 中打开生成的 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26806824/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com