我在我的页面上设置了嵌入
<embed src="http://yoursite.com/the.pdf" width="500" height="375">
加载页面时,chrome 会提示下载文件的位置。
提供文件服务的 php 确实使用内联 header
偶数PDF Object无法在任一浏览器中工作,但可以在 safari 中工作
我使用的是 Mac,但我已经确认在 Windows 上有相同的结果
最佳答案
这对我在 Mac 上的 Chrome 中有效,希望有帮助。
<head lang="en">
<script src="js/pdf.js"></script>
<script>
PDFJS.getDocument('read_me.pdf').then(function(pdf) {
// Using promise to fetch the page
pdf.getPage(1).then(function(page) {
var scale = 1.5;
var viewport = page.getViewport(scale);
//
// Prepare canvas using PDF page dimensions
//
var canvas = document.getElementById('the-canvas');
var context = canvas.getContext('2d');
canvas.height = viewport.height;
canvas.width = viewport.width;
//
// Render PDF page into canvas context
//
var renderContext = {
canvasContext: context,
viewport: viewport
};
page.render(renderContext);
});
});
</script>
</head>
<body>
<canvas id="the-canvas"></canvas>
</body>
转述自https://github.com/mozilla/pdf.js/blob/master/examples/helloworld/hello.js
干杯, 八打灵再也
关于javascript - Chrome 和 FF 下载嵌入 URL 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30469915/