prawnpdf / pdf-core

Implements low level PDF features for Prawn (experimental)
Other
23 stars 38 forks source link

undefined method `get_page_objects` for PDF::Core::ObjectStore #46

Closed keith-packard closed 2 years ago

keith-packard commented 3 years ago

I'm the debian maintainer for asciidoctor-pdf. When creating PDF files that completely fill the last page, that application calls object_id_for_page so that it can delete an extra page it creates after the end of the output:

  def object_id_for_page(page)
    page -= 1 if page.positive?
    flat_page_ids = get_page_objects(pages).flatten
    flat_page_ids[page]
  end

There's no definition of get_page_objects in this class though, and I don't see where it could inherit one from? I put together a fake version of this function which seems to at least get past the crash, but I'm reasonably sure it isn't correct:

  def get_page_objects(pages)
    pages.data
  end

I'm afraid I'm really unfamiliar with Ruby at this level, so this may not be a bug in pdf-core, but rather something missing from asciidoctor-pdf.

gettalong commented 2 years ago

It seems that the get_page_objects method was used way back when prawn-templates was still integrated into Prawn. I have added a implementation suitable for Prawn. prawn-templates implements a more sophisticated version.

matthijskooijman commented 2 years ago

@keith-packard Any plans to backport this fix into the Debian package maybe? I could not find a Debian bug report about this issue, but did find an upstream issue referencing the Debian package here: https://github.com/asciidoctor/asciidoctor-pdf/issues/1953, so it does seem people are running into this (I also did).

keith-packard commented 2 years ago

I don't maintain that debian package myself, but I have put together a patch to fix this -- please file a bug against the ruby-pdf-core package and I'll link my patch to that.

keith-packard commented 2 years ago

oh. ruby-prawn-templates replaces a file from ruby-prawn (/usr/lib/ruby/vendor_ruby/prawn/document/internals.rb). That's not gonna work on Debian, and it's a pretty bad idea in general. Sounds like there's more work to be done before this can get fixed.