NativeElixirPdfUtilities.Info (native_elixir_pdf_utilities v0.13.0)

View Source

Reads PDF document information and page geometry and updates common metadata.

Information updates append an incremental revision. The existing PDF bytes and unspecified information dictionary entries remain unchanged. XMP metadata is outside this API and is neither read nor updated.

Summary

Types

Common fields from the active PDF information dictionary.

One effective page size in PDF points.

Functions

Returns whether the active PDF trailer declares encryption.

Returns common fields from the active PDF information dictionary.

Returns the validated number of pages in a PDF.

Returns each page's effective MediaBox size and normalized rotation.

Applies a patch to common PDF information fields and returns an updated PDF.

Types

error_reason()

info()

Common fields from the active PDF information dictionary.

page_size()

One effective page size in PDF points.

Functions

encrypted?(pdf)

@spec encrypted?(binary()) ::
  {:ok, boolean()}
  | {:error,
     {error_reason(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Returns whether the active PDF trailer declares encryption.

This validates the header, cross-reference chain, and trailer without trying to decrypt or interpret encrypted document objects.

get(pdf)

@spec get(binary()) ::
  {:ok, info()}
  | {:error,
     {error_reason(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Returns common fields from the active PDF information dictionary.

Missing fields are returned as nil. PDF dates are validated and converted to NaiveDateTime; timezone suffixes are validated while the written wall-clock value is retained.

page_count(pdf)

@spec page_count(binary()) ::
  {:ok, non_neg_integer()}
  | {:error,
     {error_reason(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Returns the validated number of pages in a PDF.

page_sizes(pdf)

@spec page_sizes(binary()) ::
  {:ok, [page_size()]}
  | {:error,
     {error_reason(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Returns each page's effective MediaBox size and normalized rotation.

Width and height use PDF points and reflect page rotation. Page numbers begin at one.

put(pdf, fields)

@spec put(binary(), map() | keyword()) ::
  {:ok, binary()}
  | {:error,
     {error_reason(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Applies a patch to common PDF information fields and returns an updated PDF.

Omitted fields remain unchanged and nil removes a field. Text values must be valid UTF-8. Dates accept Date, NaiveDateTime, DateTime, ISO 8601 strings, and valid PDF date strings.