我目前正在将我的“旧”基于 Python 的聊天机器人重写为 golang。我遇到的一个问题是我无法将 PDF 转换为 jpeg。我想这样做,这样我就可以轻松地将其发送到聊天中。
已经用 bimg(根本不起作用)和 imagemagick (gopkg.in/gographics/imagick.v3/imagick) 尝试过这个,如另一个线程的答案中提供的:“ /sf/answers/3326441751/ ”
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)
Run Code Online (Sandbox Code Playgroud)
它根本不产生 jpg,它只是给我错误
ERROR_POLICY: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408
Run Code Online (Sandbox Code Playgroud)
我怎样才能使这项工作?我似乎无法为此编辑安全设置。
任何帮助表示赞赏!