Skip to content

Commit

Permalink
resolves #1357 enable fullscreen page mode if pdf-page-mode=fullscree…
Browse files Browse the repository at this point in the history
…n (PR #1366)
  • Loading branch information
mojavelinux authored Nov 7, 2019
1 parent 7af348d commit 8877a60
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[

== Unreleased

* allow initial page mode to be set to fullscreen using pdf-page-mode=fullscreen attribute or page_mode=fullscreen theme key (#1357)
* allow theme to configure content of entries in authors line on title page (#800)
* allow theme to override styles of caption on admonition blocks (#561)
* allow top value of logo and title on title page to be specified in any measurement unit
Expand Down
6 changes: 6 additions & 0 deletions docs/theming-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,12 @@ See <<Title Page>> for details.
|page:
margin-outer: 0.59in

|mode
|fullscreen
(default: _not set_)
|page:
mode: fullscreen

|size
|/~https://github.com/prawnpdf/pdf-core/blob/0.6.0/lib/pdf/core/page_geometry.rb#L16-L68[Named size^] {vbar} <<measurement-units,Measurement[width,height]>> +
(default: A4)
Expand Down
3 changes: 2 additions & 1 deletion lib/asciidoctor/pdf/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ def convert_document doc
end
end

catalog.data[:PageMode] = :FullScreen if (doc.attr 'pdf-page-mode', @theme.page_mode) == 'fullscreen'
add_outline doc, (doc.attr 'outlinelevels', toc_num_levels), toc_page_nums, num_front_matter_pages[1], has_front_cover
if state.pages.size > 0 && (initial_zoom = @theme.page_initial_zoom)
case initial_zoom.to_sym
Expand Down Expand Up @@ -3476,7 +3477,7 @@ def add_outline doc, num_levels = 2, toc_page_nums = [], num_front_matter_pages
end

catalog.data[:PageLabels] = state.store.ref Nums: pagenum_labels.flatten
catalog.data[:PageMode] = :UseOutlines
catalog.data[((doc.attr 'pdf-page-mode') || @theme.page_mode) == 'fullscreen' ? :NonFullScreenPageMode : :PageMode] = :UseOutlines
nil
end

Expand Down
16 changes: 15 additions & 1 deletion spec/outline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe 'Asciidoctor::PDF::Converter - Outline' do
context 'General' do
it 'should set /PageModes /UseOutlines in PDF catalog to enable outline hierarchy' do
it 'should set /PageMode /UseOutlines in PDF catalog to enable outline hierarchy' do
pdf = to_pdf <<~'EOS'
= Document Title
Expand All @@ -14,6 +14,20 @@
(expect pdf.catalog[:PageMode]).to eq :UseOutlines
end

it 'should set /NonFullScreenPageMode /UseOutlines in PDF catalog if fullscreen mode is enabled' do
pdf = to_pdf <<~'EOS'
= Document Title
:pdf-page-mode: fullscreen
== First
== Last
EOS

(expect pdf.catalog[:PageMode]).not_to eq :UseOutlines
(expect pdf.catalog[:NonFullScreenPageMode]).to eq :UseOutlines
end

it 'should create an outline to navigate the document structure' do
pdf = to_pdf <<~'EOS'
= Document Title
Expand Down
17 changes: 17 additions & 0 deletions spec/page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,23 @@
end
end

context 'Mode' do
it 'should set page mode to fullscreen if page_mode key in them is fullscreen' do
pdf = to_pdf 'content', pdf_theme: { page_mode: 'fullscreen' }
(expect pdf.catalog[:PageMode]).to eql :FullScreen
end

it 'should set page mode to fullscreen if pdf-page-mode attribute is fullscreen' do
pdf = to_pdf 'content', attribute_overrides: { 'pdf-page-mode' => 'fullscreen' }
(expect pdf.catalog[:PageMode]).to eql :FullScreen
end

it 'should allow pdf-page-mode attribute in document to disable fullscreen mode' do
pdf = to_pdf 'content', pdf_theme: { page_mode: 'fullscreen' }, attribute_overrides: { 'pdf-page-mode' => '' }
(expect pdf.catalog[:PageMode]).not_to eql :FullScreen
end
end

context 'Margin' do
it 'should use the margin specified in theme by default' do
input = 'content'
Expand Down

0 comments on commit 8877a60

Please sign in to comment.