Ruby scripting: create PDF with prawn

Asked by Giel Raijmakers

I'm using SikuliXIDE in Windows 8.1
I have created an errorhandler and want the error to an pdf file.
For this I wanted to use Prawn... but, I have no idea how to add a gem to the sikili.

Can you help me?
Cheers,
Giel

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

Since you are talking about Prawn, you should already now use SikuliX in the Ruby version?

Or am I misunderstanding something?

If not, then you should also have a running Ruby installation, that can handle gems.
If not, you have to do that. And install the Prawn gem.

When you have that ready, then you have to add the needed setup to the SikuliX environment for the final require 'prawn' to work.

Revision history for this message
Giel Raijmakers (graijmakers) said :
#2

Hi RaiMan,
thanks for the comment.

Yes, I already use the Ruby version of SikuliX.
Yes, I have installed Ruby, I installed the Prawn gem... but, Sikuli mentions that "no such file to load."

Do I have to set certain settings so Sikuli can find the gem?

Code I use:
################
require "prawn"

Prawn::Document.generate("hello.pdf") do
  text "Hello World!"
end
################

Revision history for this message
RaiMan (raimund-hocke) said :
#3

I am not that (J)Ruby expert, but I guess you have to add

$LOADPATH << path-to-the-folder-containing-prawn.rb

before the
require "prawn"

because the SikuliX IDE environment does not know anything about all this standard JRuby and gem eco system.

Revision history for this message
Giel Raijmakers (graijmakers) said :
#4

When I use $LOADPATH
[error] NoMethodError ( (NoMethodError) undefined method `<<' for nil:NilClass )

I added the path to the reqiuer like this:
 require "C:\\Ruby22\\lib\\ruby\\gems\\2.2.0\\gems\\prawn-2.0.1\\lib\\prawn.rb"

Then the dependend gems started: "no such file", so I inculded them also...
    require "C:\\Ruby22\\lib\\ruby\\gems\\2.2.0\\gems\\ttfunk-1.4.0\\lib\\ttfunk.rb"
    require "C:\\Ruby22\\lib\\ruby\\gems\\2.2.0\\gems\\pdf-core-0.5.1\\lib\\pdf\\core.rb"
    require "C:\\Ruby22\\lib\\ruby\\gems\\2.2.0\\gems\\prawn-2.0.1\\lib\\prawn.rb"

But still... It doesn;t seem to work. The dependencies with the other gems act up.

Revision history for this message
RaiMan (raimund-hocke) said :
#5

I am sorry, but I am not the expert in Ruby and especially Gem handling.

I guess you have to look out for a method to activate the gem loading within an already running script.

Revision history for this message
Giel Raijmakers (graijmakers) said :
#6

Thanks for the help RaiMan.
I hope I will figure this out. If so, I will update this post.

Cheers!

Can you help with this problem?

Provide an answer of your own, or ask Giel Raijmakers for more information if necessary.

To post a message you must log in.