【问题标题】:Chrome extension - "File_get_contents" of a PDF file, open in a tabChrome 扩展 - PDF 文件的“File_get_contents”,在选项卡中打开
【发布时间】:2015-05-17 06:55:54
【问题描述】:

是否有可能获取在谷歌浏览器中打开的 pdf 的文件内容。

我从 chrome 扩展、权限“activetabs”等开始...

读取选项卡的 HTML 代码正在工作,但我需要直接文件数据, 像 php 中的 file_get_contents($pdf)。

这是如何工作的?有人有经验吗?

【问题讨论】:

  • 恐怕 Chrome 没有为扩展提供任何这样的 API。您可以在crbug.com 上提交功能请求。

标签: pdf google-chrome-extension


【解决方案1】:

现在我找到了解决方案:

Javascript:

//Read file
var xhr = new XMLHttpRequest();
xhr.open('GET', 'file:///C:/Scource_File.pdf', true);
xhr.responseType = 'blob';
xhr.send();


//Send file
var xhr = new XMLHttpRequest();
var fd = new FormData();
fd.append('server-method', 'upload');
fd.append('file', blob);
xhr.open('POST', 'http://www.example.com/get_file_via_post.php', false);
xhr.send(fd);

【讨论】:

    猜你喜欢
    • 2016-11-04
    • 2011-01-25
    • 1970-01-01
    • 2019-04-12
    • 2017-01-08
    • 1970-01-01
    • 2019-05-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多