Generate pdf inside another pdf

19 views
Skip to first unread message

yogi

unread,
Jan 25, 2012, 7:09:13 AM1/25/12
to Prawn
I got two Prawn::Document subclasses, InvoiceDocument and
GroupedInvoiceDocument. The latter acts as sort of index for other
invoices and is not needed always, hence it is split into its own
class.

What I'd like to do is that when the GroupedInvoiceDocument is
required I could have something like below on my GroupInvoiceDocument
to append all the regular invoices.

def attach_invoices
@group_invoice.invoices.each do |invoice|
start_new_page
InvoiceDocument.new(invoice)
end

The above ends up with just empty pages, but how could I make this
happen?

cheers,
yogi

Brad Ediger

unread,
Feb 7, 2012, 10:00:30 PM2/7/12
to prawn...@googlegroups.com
On Wed, Jan 25, 2012 at 6:09 AM, yogi <jooga.h...@gmail.com> wrote:
> I got two Prawn::Document subclasses, InvoiceDocument and
> GroupedInvoiceDocument. The latter acts as sort of index for other
> invoices and is not needed always, hence it is split into its own
> class.
>
> What I'd like to do is that when the GroupedInvoiceDocument is
> required I could have something like below on my GroupInvoiceDocument
> to append all the regular invoices.

Because of the structure of the PDF format, it would be nontrivial to
merge two existing documents. What you could probably do in lieu of
this feature is to use Ruby modules to keep the two sets of
functionality separate but be able to mix them into the same document.

-be

Reply all
Reply to author
Forward
0 new messages