在没有工具栏的 Electron 应用程序中嵌入 pdf
我一定错过了一些非常明显的东西,但是经过几个小时的研究以及在电子文档中尝试不同的事情,我还没有找到正确的解决方案。
对于电子应用程序,我有 4 个 pdf:3 个将与电子应用程序打包在一起,1 个将来自外部网站。我需要能够全屏显示它们中的每一个,没有工具栏或其他“绒毛”。每个尺寸正好是 1 个“屏幕”,这是针对非常有限的观众的,因此我可以保证所使用的观看条件/技术。就所需功能而言,这些 pdf 可能只是巨大的图像。然而。由于 Reasons(TM),我无法将它们转换为任何其他(更易于使用)格式。
我目前正在使用 BrowserWindow,它的工作效率为 80%。我可以很好地看到 pdf 文件,但它已缩放并且仍然有工具栏。 (这将以纵向显示,因此尺寸为奇数)
$('#btn_0-0').on('click', function(e) {
e.stopPropagation()
openPDF("./app/assets/docs/TreatmentLandscape.pdf")
})
function openPDF(filePath) {
let pdfWindow = new electron.remote.BrowserWindow({
width: 1080,
height: 1920,
webPreferences: {
plugins: true
}
});
pdfWindow.loadFile(filePath)
pdfWindow.setMenu(null);
pdfWindow.on('closed', function() {
pdfWindow = null
})
}
tl;dr 另一个人正在寻找如何在电子中制作无框嵌入式 pdf。帮助 :(
I must be missing something very obvious, but after several hours on SO and in the electron docs trying different things, I've not found the right solution.
For an electron app, I have 4 pdfs: 3 are going to be packaged with the electron app, 1 will come from an external website. I need to be able to display each of them at full-screen, with no toolbars or other "fluff". Each is exactly 1 "screen" in size, and this is for a VERY restricted audience so I can guarantee the viewing conditions/technology used. In terms of the needed functionality, these pdfs could just be giant images. However. Due to Reasons(TM) I cannot convert them to any other (easier to use) format.
I am currently using a BrowserWindow, and it works 80%. I can see the pdf just fine, but it's zoomed and still has a toolbar. (This will be displayed in portrait orientation, hence the odd dimensions)
$('#btn_0-0').on('click', function(e) {
e.stopPropagation()
openPDF("./app/assets/docs/TreatmentLandscape.pdf")
})
function openPDF(filePath) {
let pdfWindow = new electron.remote.BrowserWindow({
width: 1080,
height: 1920,
webPreferences: {
plugins: true
}
});
pdfWindow.loadFile(filePath)
pdfWindow.setMenu(null);
pdfWindow.on('closed', function() {
pdfWindow = null
})
}
tl;dr Another person looking for how to do frameless embedded pdfs in electron. Help :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论