Skip to content

Commit

Permalink
resolves #2528 position foreground image correctly when page layout c…
Browse files Browse the repository at this point in the history
…hanges (PR #2529)
  • Loading branch information
mojavelinux committed Jun 17, 2024
1 parent 0a8e35c commit 9602a9a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Bug Fixes::
* prevent special character substitution from interfering with callouts in plain verbatim block (#2390)
* remove deprecated, undocumented `svg-font-family` theme key (the correct key is `svg-fallback-font-family`)
* major improvement to OTF support following release of ttfunk 1.8.0 (automatic transitive dependency of prawn)
* 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 @@ -4428,14 +4428,17 @@ def stamp_foreground_image doc, has_front_cover
if (first_page = (has_front_cover ? (pages.drop 1) : 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 @@ -1826,6 +1826,12 @@
<<<
[.text-left]
#{['lots of rambling'] * 150 * ?\n}
[page-layout=landscape]
<<<
[.text-left]
#{['lots of rambling'] * 150 * ?\n}
END
Expand Down
Binary file modified spec/reference/page-watermark.pdf
Binary file not shown.

0 comments on commit 9602a9a

Please sign in to comment.