Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7843017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:27:03+00:00 2026-06-02T16:27:03+00:00

I have a rtf file. I want to open that file using Ruby for

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:27:04+00:00Added an answer on June 2, 2026 at 4:27 pm

    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:

    # using Document class of ruby-rtf plugin
    document = Document.new(nil) 
    image = document.image("path_to_image/check.png")
    
    rtf_file = IO.read("path_to_rtf/my.rtf")
    rtf_file.gsub!('@@placeholder@@', image.to_rtf)
    File.open("#{Rails.root}/my_userdata/new_blank.rtf", "wb") {|f| f.write rtf_file }
    

    I hope it will be helpful for someone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question I want to programmatically open a RTF file in Microsoft Word using C#.
I have an RTF file that I want to display inside a web page
I have a .rtf file and want to put it in a richtextbox in
I want to view .doc, .docx, .rtf, .ppt file in iphone. But I guess
I have just tried to save a simple *.rtf file with some websites and
I have an RTF file that I need to display to a user. I
I have a report in Access that we want split and exported to .rtf
I have a RichTextBox that I wish to fill with RTF text at design
Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET =
I have file with contents in list form such as [1,'ab','fgf','ssd'] [2,'eb','ghf','hhsd'] [3,'ag','rtf','ssfdd'] I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.