开发者

how to convert rtf to image format ( jpg/png..)

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


You can use a virtual printing device, for example: http://www.joyprinter.com/


If by programmatically, you mean scripts, you could script your RTF program to open files, then export to PDF, then export the PDF to an image. At least, this kind of operation is relatively easy on OS X. You could probably do it entirely in Automator, using TextEdit and Preview. Otherwise, on OS X you could also try accessing the core services that would do the same thing. No clue on Windows though. Hope that helps!


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}"

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜