Skip to content

Commit

Permalink
backport fix for #2528 position foreground image correctly when page …
Browse files Browse the repository at this point in the history
…layout changes
  • Loading branch information
mojavelinux committed Jun 17, 2024
1 parent b9307af commit f21ccc3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ For a detailed view of what has changed, refer to the {url-repo}/commits/main[co

== Unreleased

_No changes since previous release._
Bug Fixes::

* position foreground image correctly when page layout changes (#2528)

== 2.3.17 (2024-06-01) - @mojavelinux

Expand Down
17 changes: 10 additions & 7 deletions lib/asciidoctor/pdf/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4397,14 +4397,17 @@ def stamp_foreground_image doc, has_front_cover
if (first_page = (has_front_cover ? (pages.slice 1, pages.size) : pages).find {|it| !it.imported_page? }) &&
(first_page_num = (pages.index first_page) + 1) &&
(fg_image = resolve_background_image doc, @theme, 'page-foreground-image') && fg_image[0]
go_to_page first_page_num
create_stamp 'foreground-image' do
canvas { image fg_image[0], ({ position: :center, vposition: :center }.merge fg_image[1]) }
end
stamp 'foreground-image'
(first_page_num.next..page_count).each do |num|
stamps = ::Set.new
(first_page_num..page_count).each do |num|
go_to_page num
stamp 'foreground-image' unless page.imported_page?
next if page.imported_page?
unless stamps.include? (stamp_name = %(foreground-image-#{page.layout}))
create_stamp stamp_name do
canvas { image fg_image[0], ({ position: :center, vposition: :center }.merge fg_image[1]) }
end
stamps << stamp_name
end
stamp stamp_name
end
end
end
Expand Down
6 changes: 6 additions & 0 deletions spec/page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,12 @@
<<<
[.text-left]
#{['lots of rambling'] * 150 * ?\n}
[page-layout=landscape]
<<<
[.text-left]
#{['lots of rambling'] * 150 * ?\n}
EOS
Expand Down
Binary file modified spec/reference/page-watermark.pdf
Binary file not shown.

0 comments on commit f21ccc3

Please sign in to comment.