如何使用Ruby旋转PDF文件 [英] How to rotate a PDF file using Ruby
问题描述
我正在尝试使用ruby(例如90度或180度)旋转PDF文件。我目前正在使用ImageMagick,但是我面临的问题是输出文件的质量下降了很多。
I'm trying to rotate a PDF file using ruby (e.g. 90 or 180 degrees). I'm using ImageMagick currently, however the issue I'm facing is that the quality of the output file drops a lot.
这是一个示例代码:
new_image = Magick::Image.read(image_path).first
new_image = new_image.rotate(degrees)
new_image.write(image_path)
您知道应该按顺序使用哪种技术/工具/库吗?旋转PDF后不会失去任何质量。
Do you know what technic/tool/library should be used in order to not lose any quality after rotating a PDF.
谢谢
推荐答案
您是否考虑过使用SVG进行转换?您可以使用Inkscape将您的PDF翻译为SVG
Have you considered using SVG for transformations? You could translate your PDF to SVG using Inkscape
inkscape -l out.svg in.pdf
然后在SVG中添加旋转使用转换
属性并将其转换回PDF
Then add rotation in SVG using the transform
attribute and covert it back to PDF
inkscape -A out.pdf in.svg
我意识到你了我已经要求在Ruby中提供解决方案,但万一你找不到任何可能有助于解决问题的方法。
I realise that you've asked for a solution in Ruby, but in case you won't find any this might help to solve the problem.
这篇关于如何使用Ruby旋转PDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!