Because our template system had a design that lead to corrupt documents,
we removed the feature. The prawn-templates gem was an attempt to
extract the relevant code so that others might be able to maintain
it if they wanted, but that hasn't happened.
Please don't use this broken feature, but if you *must* use it, you can
try Prawn 0.15.0 with the prawn-templates gem.
That said if you're just trying to get the page count of an existing
PDF, you can use our testing tool, PDF::Inspector for that.
page_counter = PDF::Inspector::Page.analyze(@pdf.render)
p page_counter.pages.size
More details here:
https://github.com/prawnpdf/pdf-inspector
-greg
On 9/25/14 5:38 AM, Sebastian Schasse wrote:
> Hi there,
>
> I just check out the prawn pdf library and need to count the pages of an
> existing pdf. I use prawn version 1.2.1 and ruby version 2.1.2.
>
> After some research I found posts, saying that this should work:
>
> |
> Prawn::Document.new(template:"/path/to/some.pdf").page_count
> |
>
> But actually it does not. The template option for Prawn::Document does
> not exist anymore. But there is another gem called prawn-templates,
> which extracted this option.
> With this gem I get the following Error:
>
> |
>>Prawn::Document.new(template:generated_pdf).page_count
> NoMethodError:undefinedmethod `margins' for nil:NilClass
> from
> /home/user/.rvm/gems/ruby-2.1.2/gems/prawn-1.2.1/lib/prawn/document.rb:686:in
> `generate_margin_box'
> |
>
> Any suggestions?
>
> cheers
> Sebastian
>
> --
> You received this message because you are subscribed to the Google
> Groups "Prawn" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
prawn-ruby+...@googlegroups.com
> <mailto:
prawn-ruby+...@googlegroups.com>.
> For more options, visit
https://groups.google.com/d/optout.