summaryrefslogtreecommitdiff
path: root/spec/optimizer_spec.rb
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-09-28 03:00:49 -0600
committerGitHub <noreply@github.com>2022-09-28 03:00:49 -0600
commit4df03898faefcda99bc4cd3a751a95dba3b4d690 (patch)
treef6f90dbc55fa999066ca6bc4263f9fe1f28fd973 /spec/optimizer_spec.rb
parent02fabe0da4e5aa8ac7deb9b7325adf0430f6e028 (diff)
resolves #2347 add support for passing a color mode to the default optimizer (PR #2348)
Diffstat (limited to 'spec/optimizer_spec.rb')
-rw-r--r--spec/optimizer_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/optimizer_spec.rb b/spec/optimizer_spec.rb
index 3ac9c0ba..caaa7ee7 100644
--- a/spec/optimizer_spec.rb
+++ b/spec/optimizer_spec.rb
@@ -88,6 +88,31 @@ describe 'Asciidoctor::PDF::Optimizer', if: (RSpec::ExampleGroupHelpers.gem_avai
end).to not_raise_exception
end
+ it 'should apply grayscale color mode modifier on quality when optimizing output file', visual: true do
+ %w(gray grayscale).each do |mode|
+ input_file = Pathname.new fixture_file 'with-color.adoc'
+ to_file = to_pdf_file input_file, 'optimizer-gray.pdf', attribute_overrides: { 'optimize' => %(screen:#{mode}) }
+ (expect to_file).to visually_match 'optimizer-gray.pdf'
+ end
+ end
+
+ #it 'should apply bw color mode modifier on quality when optimizing output file', visual: true do
+ # input_file = Pathname.new fixture_file 'with-color.adoc'
+ # to_file = to_pdf_file input_file, 'optimizer-bw.pdf', attribute_overrides: { 'optimize' => ':bw' }
+ # (expect to_file).to visually_match 'optimizer-bw.pdf'
+ #end
+
+ it 'should apply bw color mode modifier on quality when optimizing output file', visual: true do
+ input_file = Pathname.new fixture_file 'with-color.adoc'
+ attribute_overrides = { 'optimize' => ':bw' }
+ pdf = to_pdf input_file, attribute_overrides: attribute_overrides, analyze: true
+ (expect pdf.text.map {|it| it[:font_color] }.uniq).to eql [nil]
+ pdf = to_pdf input_file, attribute_overrides: attribute_overrides, analyze: :rect
+ rects = pdf.rectangles
+ (expect rects).to have_size 1
+ (expect rects[0][:fill_color]).to eql '818181'
+ end
+
it 'should generate PDF that conforms to specified compliance' do
input_file = Pathname.new example_file 'basic-example.adoc'
to_file = to_pdf_file input_file, 'optimizer-screen-pdf-a.pdf', attribute_overrides: { 'optimize' => 'PDF/A' }