PaperForge.Metadata (PaperForge v0.2.0)

Copy Markdown View Source

Represents document metadata stored in the PDF information dictionary.

Supported fields include:

  • title;
  • author;
  • subject;
  • keywords;
  • creator;
  • producer;
  • creation date;
  • modification date.

Text values are encoded automatically using PaperForge.StringEncoding. Latin-1-compatible text is stored as a literal PDF string, while other Unicode text is stored as UTF-16BE.

Summary

Functions

Returns whether the metadata contains no values that would be written to the PDF information dictionary.

Creates document metadata from a keyword list.

Converts metadata into a PDF information dictionary.

Types

t()

@type t() :: %PaperForge.Metadata{
  author: binary() | nil,
  creation_date: DateTime.t() | NaiveDateTime.t() | nil,
  creator: binary() | nil,
  keywords: [binary()],
  modification_date: DateTime.t() | NaiveDateTime.t() | nil,
  producer: binary() | nil,
  subject: binary() | nil,
  title: binary() | nil
}

Functions

empty?(metadata)

@spec empty?(t()) :: boolean()

Returns whether the metadata contains no values that would be written to the PDF information dictionary.

new(options \\ [])

@spec new(keyword()) :: t()

Creates document metadata from a keyword list.

Supported options

  • :title
  • :author
  • :subject
  • :keywords
  • :creator
  • :producer
  • :creation_date
  • :modification_date

Example

PaperForge.Metadata.new(
  title: "Reporte de México",
  author: "Manuel García",
  keywords: ["PDF", "Elixir", "PaperForge"],
  creation_date: DateTime.utc_now()
)

to_dictionary(metadata)

@spec to_dictionary(t()) :: map()

Converts metadata into a PDF information dictionary.

Empty and nil values are omitted.