JackieMium / my_blog

在 Issues 中建立的个人博客
GNU General Public License v3.0
31 stars 12 forks source link

在 Debian 中使用 Zotero 文献管理软件 #5

Open JackieMium opened 6 years ago

JackieMium commented 6 years ago
2017-05-14 20:51:47

我在 Debian 中用 Zotero 管理文献时发现 PDF 导入后获取文件信息获取不到。以下时解决过程记录。

Install the pdftotext and pdfinfo programs:

sudo apt-get install poppler-utils

Find the kernel and architecture:

uname --kernel-name --machine

In the Zotero data directory create a symbolic link to the installed programs. The printed kernel-name and machine is part of the link's name:

cd ~/.zotero
ln -s $(which pdftotext) pdftotext-$(uname -s)-$(uname -m)
ln -s $(which pdfinfo) pdfinfo-$(uname -s)-$(uname -m)

Install a small helper script to alter pdftotext paramaters:

cd ~/.zotero
wget -O pdfinfo.sh https://raw.githubusercontent.com/zotero/zotero/4.0/resource/redirect.sh
chmod a+x pdfinfo.sh

Create some files named *.version containing the version numbers of the utilities. The version number appears in the third field of the first line on stderr:

cd ~/.zotero
pdftotext -v 2>&1 | head -1 | cut -d ' ' -f3 > pdftotext-$(uname -s)-$(uname -m).version
pdfinfo -v 2>&1 | head -1 | cut -d ' ' -f3 > pdfinfo-$(uname -s)-$(uname -m).version

Start Zotero's gear icon, "Preferences"-"Search" should report something like:

PDF indexing
  pdftotext version 0.26.5 is installed
  pdfinfo version 0.26.5 is installed

Do not press "check for update". The usual maintenance of the operating system will keep those utilities up to date.

更多

如果上述完成还不可用,运行这个脚本:

#!/bin/bash

version=$(dpkg-query -W -f='${Version}' poppler-utils || echo "please_install_poppler-utils")

totextbinary='pdftotext-Linux-x86_64'
infobinary='pdfinfo-Linux-x86_64'
infohack='pdfinfo.sh'

for zoteropath in $(find $HOME/.zotero $HOME/.mozilla -name zotero.sqlite -exec dirname {} \;)
do
    echo $version > $zoteropath/"$totextbinary.version"
    echo $version > $zoteropath/"$infobinary.version"

    ln -s /usr/bin/pdftotext "$zoteropath/$totextbinary"
    ln -s /usr/bin/pdfinfo "$zoteropath/$infobinary"

    cat > $zoteropath/$infohack << EOF

#!/bin/sh
if [ -z "\$1" ] || [ -z "\$2" ] || [ -z "\$3" ]; then
    echo "Usage: $0 cmd source output.txt"
    exit 1
fi
"\$1" "\$2" > "\$3"
EOF

    chmod +x $zoteropath/$infohack

done

脚本来自 bugs.debian.org