-Hello Sandeep here. I am an apprentice to the Jedi Master Yoda. My master believes the force is strong in the Ruby community and has chosen me for a simple task to complete using the Ruby langauge:
I need to use the Prawn PDF gem to accomplish the task. I have an existing pdf document called Dooku.pdf - it contains sensitive information on the Evil Count Dooku's activities. In Dooku.pdf there is text called {galaxy}. {galaxy} is always in the same location on every page of the pdf document.
I need to open Dooku.pdf, replace each instance of {galaxy} with {planet} and then save/close Dooku.pdf. How do I accomplish this task using the Prawn PDF gem?
-May the force be with you.
You can't. Prawn is for writing PDFs, not reading them.
1) I'm a star wars fan and all, but damn.
2) Your "simple task" is not even remotely simple. It's not that hard to COVER the existing text... but REPLACING IT is another mater entirely. And forget reflowing existing text. All-but-impossible.
If covering it will suffice, then you need only draw a rectangle filled with the background color over your first string, then draw your second string on top of it. I'm not familiar with Prawn PDF, so I'll leave the implementation details as an Exercise For the Reader.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With