prawn-table icon indicating copy to clipboard operation
prawn-table copied to clipboard

Table is missing and appears to interrupt generation without errors in embedded Ruby (Sketchup)

Open spetroll opened this issue 9 years ago • 3 comments

Hi,

I'm developing Plugins for Sketchup, which uses its own embedded ruby interpreter (2.0.0 p247) and API to allow communication with the core software.

While looking for a pdf generator suitable to export reports, I've found prawn to be very interesting and first tests are promising. However, we need to include some tables, and there appears to be a problem that with the generation, but no errors are shown while the incomplete pdf file is created. It also appears to interrupt the process somehow, elements after the table are missing too.

require 'prawn'
require 'prawn/table'

Prawn::Document.generate("test.pdf") do
  text "hello"
  table([["foo", "bar " * 10, "baz"],["baz", "bar", "foo " * 10]])
  text "world"
end
system `start test.pdf`

This works fine when run in ruby locally local, but does only print hello sketchup when executed in Sketchup.

Are there any debug options I can use to get more feedback and help you with looking what causes this problem?

spetroll avatar Feb 19 '16 08:02 spetroll

A bit more information I could gather myself:

Storing the table with make_table in a variable, I get this output when I use pretty-print. When I don't call draw it prints the world correctly, with draw I get the incorrect output of my previous example.

I did the same for the document itself: output

spetroll avatar Feb 19 '16 09:02 spetroll

@SvenPetroll I have no experience with SketchUp. Could you please write a short instruction how one like me might reproduce the issue?

As for debug option. There's none in Prawn-Table I know of. Maybe using Ruby's debug options would help. Check Ruby pre-defined variables documentation for $DEBUG and $VERBOSE. Maybe that would give you more information.

pointlessone avatar Feb 19 '16 09:02 pointlessone

  1. Download a Sketchup version suitable to your system, I'm using Sketchup 2016 Pro x64 which has a trial, but you can download Sketchup 2016 Make for free.
  2. Start Sketchup, toggle the Ruby Console with Windows -> Ruby Console
  3. Install prawn into the embedded ruby by using Gem.install 'prawn' and Gem.install 'prawn-table'
  4. Put this file into AppData\Roaming\SketchUp\SketchUp 2016\SketchUp\Plugins on Windows, or Library > Application Support > SketchUp 2016 > SketchUp > Plugins on Mac, you may need to create the Plugins folder
  5. Restart Sketchup, a new menu item should appear under Extensions, which will generate the pdf file
  6. Alternatively, you can use the Ruby Console similarly to irb.

spetroll avatar Feb 19 '16 10:02 spetroll