Sha256: f06b46cc63438c7217b57c42f0b64e5300887eda598f4b48ba5f58e61fd3aaab

Contents?: true

Size: 1.35 KB

Versions: 15

Compression:

Stored size: 1.35 KB

Contents

# -*- encoding: utf-8 -*-

require 'stringio'
require 'test_helper'
require 'hexapdf/document'

describe HexaPDF::Task::PDFA do
  before do
    @doc = HexaPDF::Document.new
  end

  it "fails if the given PDF/A level is invalid" do
    assert_raises(ArgumentError) { @doc.task(:pdfa, level: '1a') }
    assert_raises(ArgumentError) { @doc.task(:pdfa, level: '2a') }
    assert_raises(ArgumentError) { @doc.task(:pdfa, level: '3a') }
    assert_raises(ArgumentError) { @doc.task(:pdfa, level: '4e') }
    assert_raises(ArgumentError) { @doc.task(:pdfa, level: 'something') }
  end

  it "removes the standard 14 PDF font loader" do
    @doc.task(:pdfa)
    assert_raises(HexaPDF::Error) { @doc.fonts.add('Helvetia') }
  end

  it "adds the necessary XMP metadata entries before the document is written" do
    @doc.task(:pdfa, level: '3b')
    @doc.write(StringIO.new)
    assert_equal('3', @doc.metadata.property('pdfaid', 'part'))
    assert_equal('B', @doc.metadata.property('pdfaid', 'conformance'))
  end

  it "adds an RGB output intent before the document is written" do
    @doc.task(:pdfa)
    @doc.write(StringIO.new)
    oi = @doc.catalog[:OutputIntents].first
    assert_equal(:GTS_PDFA1, oi[:S])
    assert_equal('sRGB2014.icc', oi[:OutputConditionIdentifier])
    assert_equal('sRGB2014.icc', oi[:Info])
    assert_kind_of(HexaPDF::Stream, oi[:DestOutputProfile])
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
hexapdf-1.1.1 test/hexapdf/task/test_pdfa.rb
hexapdf-1.1.0 test/hexapdf/task/test_pdfa.rb
hexapdf-1.0.3 test/hexapdf/task/test_pdfa.rb
hexapdf-1.0.2 test/hexapdf/task/test_pdfa.rb
hexapdf-1.0.1 test/hexapdf/task/test_pdfa.rb
hexapdf-1.0.0 test/hexapdf/task/test_pdfa.rb
hexapdf-0.47.0 test/hexapdf/task/test_pdfa.rb
hexapdf-0.46.0 test/hexapdf/task/test_pdfa.rb
hexapdf-0.45.0 test/hexapdf/task/test_pdfa.rb
hexapdf-0.44.0 test/hexapdf/task/test_pdfa.rb
hexapdf-0.41.0 test/hexapdf/task/test_pdfa.rb
hexapdf-0.40.0 test/hexapdf/task/test_pdfa.rb
hexapdf-0.39.1 test/hexapdf/task/test_pdfa.rb
hexapdf-0.39.0 test/hexapdf/task/test_pdfa.rb
hexapdf-0.38.0 test/hexapdf/task/test_pdfa.rb