Chrome 内置 PDF 浏览功能,在下便打算把它首选为默认 PDF 阅读器,但是在虚拟终端里不知要执行怎样的命令才能通过 Chrome 打开当前目录下的任意 PDF 文件。
假设当前工作目录下有 example.pdf
且 Chrome 的启动命令为 google-chrome
,当执行命令 google-chrome example.pdf
时,Chrome 能启动且会新建窗口并尝试载入,但其地址栏是 http://example.pdf/
,并非理想的 file:///path/to/example.pdf/
。
谢谢!
阿神2017-04-17 11:28:00
If you use Linux, use this script of mine:
#! /bin/bash
chrome_command="google-chrome"
if [ $# -ne 1 ]; then
echo "Usage: rrreee <pdf-file>"
exit 1
fi
# get the absolute path of the file
absolute_path=`readlink -e ""`
# if the file exist, open the file with chrome
if [ -z "$absolute_path" ]; then
echo " does not exist!"
exit 1
else
file_url="file://$absolute_path"
$chrome_command "$file_url"
fi
chrome-file
,chmod +x chrome-file
, sudo cp chrome-file /usr/local/bin
. chrome-file <file>
to open the file in chrome by simply giving the relative path to the file.
Supported file types include html, pdf, txt, pictures, etc. Try it!
大家讲道理2017-04-17 11:28:00
You need to have pdf extension
and then
chromium path (path is your pdf file path + file name)