如何将rtf转换为图像格式(jpg/png ..) [英] how to convert rtf to image format ( jpg/png..)
问题描述
我需要将包含图像(jpgs/pngs)的rtf文档转换为图像格式 jpgs或pngs的编程方式,您对此有任何想法吗? 在服务器端(网络) 谢谢
i need to convert rtf document that contains images (jpgs/pngs ) to image format jpgs or pngs programmaticly , do you have any ideas on how to do it ? on server side (web) Thanks
推荐答案
您可能想编写一个由cronjob执行的bash脚本.因此,在定义的时间或定义的时间段之后,您会将rtf文件转换为jpgs.
尽管我不知道这是否可以满足您的程序化"需求..这是如何进行此转换的方法:
要转换rtf文件,请使用诸如图像之类的高级"功能,例如,您需要unoconv,这需要安装libreoffice.
You might want to write a bash script to be executed by a cronjob. So at a defined time, or after a defined period, you will have your rtf files converted into jpgs.
Though I don't know if this might satisfy your "programmatic" need .. here is how to do this conversion:
To convert rtf files contain "advanced" features like images, as in your case, you need unoconv, which requires libreoffice to be installed.
unoconv -f pdf "${input_file}"
否则,仅供参考,因为这不是您的情况,如果rtf文件仅包含文本,则可以通过使用级联转换(如p
Otherwise, just for reference because it's not your case, if the rtf files contain only simply text you can avoid the requirement to have libreoffice installed by using a cascade conversion like
// convert rtf to txt
unrtf --text "input_file.rtf" > "temp.txt"
// convert txt to pdf
enscript "temp.txt" -o - | ps2pdf - "temp.pdf"
// convert pdf to jpg
convert -quality 100 -append "temp.pdf" "output.jpg"
// remove temp files
trash "temp.txt" "temp.pdf" // or rm if you prefer
这篇关于如何将rtf转换为图像格式(jpg/png ..)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!