Hello,
it really depends on the complexity of the change you want to make on the document contents.
PDF uses some kind of a PostScript-like syntax to render the text and graphics on a page. While this language is easy to interpret and offers and lot of flexibility in the rendering process, it also makes it much harder to modify a document in a generic manner.
For example, instead of rendering text line by line, some PDF creators (such as LaTeX) decide to generate PostScript instructions that will render each glyph individually at arbitrary positions (without using the space character at all). That makes it difficult to extract text contents, since you have to use heuristics to find spaces and line breaks. Given that those heuristics also depends on the font metrics used, reconstructing words an paragraphs can then be quite difficult.
Origami can only allows you to modify raw PostScript-like instructions. Those instructions are stored into the Contents stream of each page.
Usually, I prefer to use the shell provided with Origami for that purpose. Since this was a frequently asked feature, I added an additional Page#edit method in the shell to directly modify the contents stream as inline.
So first, run the shell (in the bin directory of Origami, might been already added to your PATH if you installed the gem):
$ pdfsh
Welcome to the PDF shell (Origami release 1.2.4) [OpenSSL: yes, JavaScript: yes]
Open the target document:
>>> pdf = PDF.read "target.pdf"
You can setup your prefered text editor into your EDITOR environment variable. PDF#edit will fire up the editor with the page contents, then any changes made when you close the editor will be pushed back into the original stream contents.
For example, to directly edit the first page:
>>> pdf.pages.first.edit
You can also specify an editor as an argument, for example if you're on Windows:
>>> pdf.pages.first.edit 'notepad'
Save the file, close the editor, and the page contents will be automatically updated. You can also call the edit method on any stream in the document.
Then you'll have to finally save the resulting PDF:
>>> pdf.save 'updated.pdf'
You can find the set of PDF instructions if the PDF specification. Text instructions are always present between BT and ET operators.
Operators that can then be used to render text are: Tj, TJ, ' and "
Hope this will help you.
Regards,
Guillaume