I have a rtf file.
I want to open that file using Ruby for replacing some placeholders by image.
I was looking around ruby-rtf. But it is not suitable for parsing rtf, only for creating brand new rtf.
Could anyone help me?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I have found solution!
First, You have to add a placeholder to your rtf file. For that you have to open rtf file with MS Word and place it in particular position. For example, your placeholder may be named like @@placeholder@@.
Second, open saved on step 1 rtf file with notepad so that to clear up a placeholder. Ms word sometimes may add “garbage” tags to your placeholder (@@pla rtlch\fcs1 \af39\afs20 \ltrch\fcs0 \b\f39\fs20\insrsid14101935\charrsi ceholder@@). You should correct it so that to get @@placeholder@@.
Third, use ruby-rtf.
At last, code for inserting image:
I hope it will be helpful for someone.