class HexaPDF::CLI::Modify
Modifies a PDF file:
-
Decrypts or encrypts the resulting output PDF file.
-
Generates or deletes object and cross-reference streams.
-
Optimizes the output PDF by merging the revisions of a PDF file and removes unused entries.
Private Instance Methods
arrange_pages(doc)
click to toggle source
Arranges the pages of the document as specified with the –pages option.
# File lib/hexapdf/cli/modify.rb, line 93 def arrange_pages(doc) all_pages = doc.pages.to_a new_page_tree = doc.add({Type: :Pages}) parse_pages_specification(@pages, all_pages.length).each do |index, rotation| page = all_pages[index] page.value.update(page.copy_inherited_values) if rotation == :none page.delete(:Rotate) elsif rotation.kind_of?(Integer) page.rotate(rotation) end new_page_tree.add_page(page) end doc.catalog[:Pages] = new_page_tree remove_unused_pages(doc) doc.pages.add unless doc.pages.count > 0 end