Method: CombinePDF::PDF#remove

Defined in:
lib/combine_pdf/pdf_public.rb

#remove(page_index) ⇒ Object

removes a PDF page from the file and the catalog

returns the removed page.

returns nil if failed or if out of bounds.

page_index

the page’s index in the zero (0) based page array. negative numbers represent a count backwards (-1 being the end of the page array and 0 being the begining).



340
341
342
343
344
345
346
# File 'lib/combine_pdf/pdf_public.rb', line 340

def remove(page_index)
  catalog = rebuild_catalog
  pages_array = catalog[:Pages][:referenced_object][:Kids]
  removed_page = pages_array.delete_at page_index
  catalog[:Pages][:referenced_object][:Count] = pages_array.length
  removed_page
end