【发布时间】:2019-09-24 11:12:07
【问题描述】:
我目前正在将我的“旧”基于 Python 的聊天机器人重写为 golang。 我遇到的一个问题是我无法将 PDF 转换为 jpeg。我想这样做,以便可以轻松地将其发送到聊天中。
已经尝试过 bimg(根本不起作用)和 imagemagick(gopkg.in/gographics/imagick.v3/imagick),正如另一个线程的答案中提供的那样:“https://stackoverflow.com/a/47520596/7502507”
imagick.Initialize()
defer imagick.Terminate()
mw := imagick.NewMagickWand()
defer mw.Destroy()
mw.ReadImage(pdf)
mw.SetIteratorIndex(0) // This being the page offset
mw.SetImageFormat("jpg")
mw.WriteImage(image)
它根本不会生成 jpg,它只是给我一个错误
ERROR_POLICY: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408
我怎样才能做到这一点?我似乎无法为此编辑安全设置。
感谢任何帮助!
【问题讨论】:
-
也许可以通过提升权限来解决问题?
-
显然是由于Ghostscript中的错误,您必须修改您
policy.xml或更新Ghostscript包(已发布修复):stackoverflow.com/questions/52998331/…