Forum How do I...?

Using Princely with Ruby on Rails on Windows

dwhitby
Hi,

I am trying to get Prince to work with a Ruby on Rails application running on Windows Vista. I am trying to use the Princely plugin but am having problems and was hoping somebody had experience using the plugin in the same environment as me.

I can get the basic command line pdf generation to work, e.g

prince input.html output.pdf

but I am trying to get the render functionality in the plugin to work but am having problems. When the file attempts to render it works and sends me a pdf file to download but when I open it it tells me the file is broken and cannot be repaired. When I look in the prince log it says

error: could not load input file

I already slightly modified the file so that the path points to the correct executable inside prince/engine/bin/ and also read the comments on the nullislove site but neither has helped me.

I am running Prince 6.0.

Any help would be much appreciated as I am banging my head against a wall right now trying to figure it out.

Thanks
mikeday
Prince must be running, or you wouldn't be getting any log messages. Is that the only error or warning message in the log file? Are there other parsing errors?
dwhitby
Hi there,

I actually tried it again this morning and now it works as expected. Could be that I needed to reboot my machine. I did find that I need to add this line to the prince.lib pdf_from_string method which is apparently required if you are on windows but not anything else:

pdf.binmode

otherwise it would tell me the pdf it generated was damaged. It's discussed in this issue on github:

http://github.com/mbleigh/princely/issues#issue/1

It's weird though as I did try this yesterday and it didn't work but then I tried again this morning and it worked fine - which makes me wonder if I needed to reboot after installing prince?

Anyway, the issue was solved for me - at last!
mikeday
You should not need to reboot after installing Prince, as it does not modify any system settings or components. The binmode change makes sense, otherwise the binary PDF file may be corrupted due to Windows mangling newline characters.