pdftk在Debian上无法生成fdf [错误:无法找到文件]。

huangapple go评论70阅读模式
英文:

pdftk debian can't generate fdf [error : Unable to find file]

问题

我在debian 10上。我尝试使用pdftk来使用generated_fdf命令。当我只运行以下命令时:

apt-get install pdftk

然后执行:

pdftk a.pdf generated_fdf output a.fdf

它输出错误信息:

Error: 找不到文件。
Error: 无法打开输入PDF文件:
    generated_fdf
遇到错误。未创建任何输出。

我猜可能是debian存储库不是最新的,所以我决定从git存储库构建它,然后我使用了:

java -jar /lib/pdftk/build/jar/pdftk.jar  a.pdf generate_fdf output a.fdf

这次它起作用了!!!
所以为了在开发(debian),测试(ubuntu)和生产(Windows)中拥有相同的代码,我决定在这里创建一个文件usr/bin/pdftk

#!/usr/bin/env sh
echo "pdftk_perso"
ls -l "$1"
whoami
java -jar /lib/pdftk/build/jar/pdftk.jar "$@"

现在的输出是:

pdftk_perso
-rw-r--r-- 1 user user 208557 Sep 22 16:06 a.pdf
user
Error: 找不到文件。
Error: 无法打开输入PDF文件:
   generated_fdf
遇到错误。未创建任何输出。
完成。由于输入错误,未创建任何输出。

所以,再次尝试时似乎仍然无法正常工作,就像它试图找到名为"generated_fdf"的文件一样。

值得注意的是,它在Windows和Ubuntu上都能正常工作。

英文:

I'm on debian 10. I was trying to use pdftk in order to use the generated_fdf command.
When I just

apt-get install pdftk

then

pdftk a.pdf generated_fdf output a.fdf

It output

    Error: Unable to find file.
    Error: Failed to open input PDF file:
        generated_fdf
    Errors encountered.  No output created.

I figured maybe the debian repo is not up to date so I decided to build it from the git repo
then I used :

java -jar /lib/pdftk/build/jar/pdftk.jar  a.pdf generate_fdf output a.fdf

it worked !!!
So in order to have the same code in dev (debian), testing (ubuntu) , prod (Windows) I decided to create a file here usr/bin/pdftk

#!/usr/bin/env sh
echo "pdftk_perso"
ls -l "$1"
whoami
java -jar /lib/pdftk/build/jar/pdftk.jar "$@"

the output is now

pdftk_perso
-rw-r--r-- 1 user user 208557 Sep 22 16:06 a.pdf
user
Error: Unable to find file.
Error: Failed to open input PDF file:
   generated_fdf
Errors encountered.  No output created.
Done.  Input errors, so no output created.

So again it's not working as if it was trying to find the file named "generated_fdf"

FYI it works fine with windows and ubuntu

答案1

得分: 2

你将pdftk a.pdf generated_fdf output a.fdf误键为generated_fdf,但它并非一个命令。正确的命令是generate_fdf,用于创建一个fdf文件。你已经在Windows上自行更正了该命令。请比较一下你两个命令之间的区别。另外,PDFTK并没有报错,它是在指出找不到文件,所以命令本身不正确。请在Debian终端中运行相同的命令,它会正常工作。

pdftk "Business model.pdf" generate_fdf output k.fdf

如果你遇到问题,请告诉我。

英文:

You have mistyped pdftk a.pdf generated_fdf output a.fdf as generated_fdf is not a command. The command is generate_fdf to create an fdf file. You have corrected the command by yourself on windows. See the difference in your both commands. Also PDFTK is not giving an error, it is saying that the file was not found, so the command is not right by itself. Run the same command via your debian terminal, it will work

pdftk "Business model.pdf" generate_fdf output k.fdf

let me know if you face an issue.

答案2

得分: -1

同时我也遇到了相同的问题,但是通过以下步骤解决了我的问题 -

  1. 运行命令:sudo ln -s /snap/pdftk/current/usr/bin/pdftk /usr/bin/pdftk
  2. 运行命令:sudo ln -fs /snap/pdftk/current/usr/bin/pdftk /usr/bin/pdftk

注意:你可能需要退出登录并重新登录以重置会话。

使用以下命令将 input.pdf 文件合并并输出为 new.pdf 文件:pdftk input.pdf cat output new.pdf

英文:

Also i am facing same issue, But from following steps resolved my issue -

  1. sudo ln -s /snap/pdftk/current/usr/bin/pdftk /usr/bin/pdftk
  2. sudo ln -fs /snap/pdftk/current/usr/bin/pdftk /usr/bin/pdftk

Note: You may need to logout and log back in to reset your session.

pdftk input.pdf cat output new.pdf

huangapple
  • 本文由 发表于 2020年9月23日 01:42:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/64015067.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定