summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-05-25 01:39:39 -0600
committerDan Allen <dan.j.allen@gmail.com>2022-05-25 01:39:39 -0600
commit56776e3affea9b4b15c3f79053f7ca569602d9a2 (patch)
treeb88a50050cabe382bcdb6d209aa31a3333207144
parent54c6651263cec0119a5c91a0cebb813a308c07d1 (diff)
log warning if title page contents overruns the bounds of a single page
-rw-r--r--CHANGELOG.adoc2
-rw-r--r--lib/asciidoctor/pdf/converter.rb4
-rw-r--r--spec/title_page_spec.rb21
3 files changed, 16 insertions, 11 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index ba798e95..5c84a929 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -15,7 +15,7 @@ Bug Fixes::
* adjust TrimBox to fit inside of BleedBox when using optimizer and compliance is PDF/X (#2203)
* set height of resized image to available height to avoid float precision error when scaling down image to fit page (#2205)
-* prevent content on title page from exceeding the bounds of a single page; restriction applies to `ink_title_page`
+* prevent content on title page from overrunning the bounds of a single page and warn; restriction applies to `ink_title_page`
== 2.0.2 (2022-05-22) - @mojavelinux
diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb
index 5b74f140..13287a69 100644
--- a/lib/asciidoctor/pdf/converter.rb
+++ b/lib/asciidoctor/pdf/converter.rb
@@ -174,7 +174,9 @@ module Asciidoctor
if (has_title_page = (title_page_on = doc.doctype == 'book' || (doc.attr? 'title-page')) && (start_title_page doc))
# NOTE: the base font must be set before any content is written to the main or scratch document
font @theme.base_font_family, size: @root_font_size, style: @theme.base_font_style
- perform_on_single_page { ink_title_page doc }
+ if perform_on_single_page { ink_title_page doc }
+ log :warn, 'the title page contents has been truncated to prevent it from overrunning the bounds of a single page'
+ end
start_new_page
else
@page_margin_by_side[:cover] = @page_margin_by_side[:recto] if @media == 'prepress' && page_number == 0
diff --git a/spec/title_page_spec.rb b/spec/title_page_spec.rb
index 1c5a9342..d812c8dc 100644
--- a/spec/title_page_spec.rb
+++ b/spec/title_page_spec.rb
@@ -1228,7 +1228,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do
(expect title_page_images[0].data).to eql image_data
end
- it 'should restrain content of title page to a single page' do
+ it '.only should truncate contents of title page so it does not exceed the height of a single page' do
pdf_theme = {
title_page_title_top: '50%',
title_page_title_font_size: 92,
@@ -1236,16 +1236,19 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do
title_page_authors_font_size: 64,
}
- pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true
- = Document Title
- Author Name
- v1.0
- :doctype: book
+ pdf = nil
+ (expect do
+ pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true
+ = Document Title
+ Author Name
+ v1.0
+ :doctype: book
- == First Chapter
+ == First Chapter
- content
- EOS
+ content
+ EOS
+ end).to log_message severity: :WARN, message: 'the title page contents has been truncated to prevent it from overrunning the bounds of a single page'
(expect pdf.pages).to have_size 2
author_text = pdf.find_unique_text 'Author Name'