Sha256: c8bc75bb023bc96f2ad4e649fb572483de4a0aa8e062c956539645bb2c9c90c3

Contents?: true

Size: 1.1 KB

Versions: 40

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

class PDF::Core::Page
  InitialPageContent = %(q\n)

  # Record the page's current state as the tare content stream (i.e., empty, meaning no content has been written).
  def tare_content_stream
    @tare_content_stream = content.stream.filtered_stream
  end

  # Returns whether the current page is empty based on tare content stream (i.e., no content has been written).
  # Returns false if a page has not yet been created.
  def empty?
    content.stream.filtered_stream == (@tare_content_stream ||= InitialPageContent) && document.page_number > 0
  end

  # Flags this page as imported.
  #
  def imported
    @imported_page = true
  end

  alias imported_page imported

  # Reset the content of the page.
  # Note that this method may leave behind an orphaned background image.
  def reset_content
    return if content.stream.filtered_stream == InitialPageContent
    xobjects.clear
    ext_gstates.clear
    new_content = document.state.store[document.ref({})]
    new_content << 'q' << ?\n
    content.replace new_content
    @tare_content_stream = InitialPageContent
    nil
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
asciidoctor-pdf-2.3.19 lib/asciidoctor/pdf/ext/pdf-core/page.rb
asciidoctor-pdf-2.3.18 lib/asciidoctor/pdf/ext/pdf-core/page.rb
asciidoctor-pdf-2.3.17 lib/asciidoctor/pdf/ext/pdf-core/page.rb
asciidoctor-pdf-2.3.16 lib/asciidoctor/pdf/ext/pdf-core/page.rb
asciidoctor-pdf-2.3.15 lib/asciidoctor/pdf/ext/pdf-core/page.rb
asciidoctor-pdf-2.3.14 lib/asciidoctor/pdf/ext/pdf-core/page.rb
asciidoctor-pdf-2.3.13 lib/asciidoctor/pdf/ext/pdf-core/page.rb
asciidoctor-pdf-2.3.12 lib/asciidoctor/pdf/ext/pdf-core/page.rb
asciidoctor-pdf-2.3.11 lib/asciidoctor/pdf/ext/pdf-core/page.rb
asciidoctor-pdf-2.3.10 lib/asciidoctor/pdf/ext/pdf-core/page.rb
asciidoctor-pdf-2.3.9 lib/asciidoctor/pdf/ext/pdf-core/page.rb
asciidoctor-pdf-2.3.8 lib/asciidoctor/pdf/ext/pdf-core/page.rb
asciidoctor-pdf-2.3.7 lib/asciidoctor/pdf/ext/pdf-core/page.rb
asciidoctor-pdf-2.3.6 lib/asciidoctor/pdf/ext/pdf-core/page.rb
asciidoctor-pdf-2.3.5 lib/asciidoctor/pdf/ext/pdf-core/page.rb
asciidoctor-pdf-2.3.4 lib/asciidoctor/pdf/ext/pdf-core/page.rb
asciidoctor-pdf-2.3.3 lib/asciidoctor/pdf/ext/pdf-core/page.rb
asciidoctor-pdf-2.3.2 lib/asciidoctor/pdf/ext/pdf-core/page.rb
asciidoctor-pdf-2.3.1 lib/asciidoctor/pdf/ext/pdf-core/page.rb
asciidoctor-pdf-2.3.0 lib/asciidoctor/pdf/ext/pdf-core/page.rb