# -*- encoding: utf-8; frozen_string_literal: true -*-
#
#--
# This file is part of HexaPDF.
#
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
# Copyright (C) 2014-2019 Thomas Leitner
#
# HexaPDF is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License version 3 as
# published by the Free Software Foundation with the addition of the
# following permission added to Section 15 as permitted in Section 7(a):
# FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
# THOMAS LEITNER, THOMAS LEITNER DISCLAIMS THE WARRANTY OF NON
# INFRINGEMENT OF THIRD PARTY RIGHTS.
#
# HexaPDF is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with HexaPDF. If not, see .
#
# The interactive user interfaces in modified source and object code
# versions of HexaPDF must display Appropriate Legal Notices, as required
# under Section 5 of the GNU Affero General Public License version 3.
#
# In accordance with Section 7(b) of the GNU Affero General Public
# License, a covered work must retain the producer line in every PDF that
# is created or manipulated using HexaPDF.
#
# If the GNU Affero General Public License doesn't fit your need,
# commercial licenses are available at .
#++
require 'hexapdf/dictionary'
require 'hexapdf/utils/bit_field'
module HexaPDF
module Type
# Annotations are used to associate objects like notes, sounds or movies with a location on a
# PDF page or allow the user to interact with a PDF document using a keyboard or mouse.
#
# See: PDF1.7 s12.5
class Annotation < Dictionary
extend Utils::BitField
define_type :Annot
define_field :Type, type: Symbol, default: type
define_field :Subtype, type: Symbol, required: true
define_field :Rect, type: Rectangle, required: true
define_field :Contents, type: String
define_field :P, type: Dictionary, version: '1.3'
define_field :NM, type: String, version: '1.4'
define_field :M, type: PDFDate, version: '1.1'
define_field :F, type: Integer, default: 0, version: '1.1'
define_field :AP, type: Dictionary, version: '1.2'
define_field :AS, type: Symbol, version: '1.2'
define_field :Border, type: PDFArray, default: [0, 0, 1]
define_field :C, type: PDFArray, version: '1.1'
define_field :StructParent, type: Integer, version: '1.3'
define_field :OC, type: Dictionary, version: '1.5'
bit_field(:raw_flags, {invisible: 0, hidden: 1, print: 2, no_zoom: 3, no_rotate: 4,
no_view: 5, read_only: 6, locked: 7, toggle_no_view: 8,
locked_contents: 9},
lister: "flags", getter: "flagged?", setter: "flag")
private
# Helper method for bit field getter access.
def raw_flags
self[:F]
end
# Helper method for bit field setter access.
def raw_flags=(value)
self[:F] = value
end
end
end
end