Resource limits

View Source

The library limits document size and processing work. When a limit is reached, the operation returns a diagnostic, usually with reason :resource_limit_exceeded.

Configure limits

Set only the values you want to change in config/config.exs or config/runtime.exs:

config :native_elixir_pdf_utilities,
  limits: [
    max_pdf_input_bytes: 75_000_000,
    max_merge_inputs: 20
  ]

Unspecified settings keep their defaults. Restart the application after a change. Limits apply across the application and cannot be overridden for one call. Invalid settings prevent startup and identify the problem.

Values must be positive integers. Aggregate image and metadata limits must allow at least one maximum-size item. The settings below do not impose an application-wide memory cap, timeout, or general HTML-source/output byte limit.

PDF inputs

These limits apply when reading existing PDFs.

SettingDefaultApplies to
max_pdf_numeric_magnitude1,000,000,000Absolute numeric operands and font metrics used for text extraction, and shared PDF geometry arrays
max_pdf_input_bytes50,000,000One PDF input
max_pdf_objects100,000Parsed PDF objects
max_pdf_object_stream_entries10,000Entries in one PDF object stream
max_pdf_pages10,000Pages in one PDF
max_pdf_page_tree_depth1,000PDF page-tree nesting
max_pdf_reference_chain_depth1,000Indirect-reference nesting
max_pdf_reference_resolution_work25,000Aggregate reference resolutions
max_pdf_value_depth100Nested PDF arrays and dictionaries
max_pdf_decoded_stream_bytes25,000,000One decoded PDF stream
max_pdf_decompression_ratio100Decoded-to-encoded stream ratio
max_pdf_xref_length_candidates1,000Candidate indirect /Length objects
max_pdf_xref_revisions1,000Incremental cross-reference revisions

HTML, images, and layout

SettingDefaultApplies to
max_svg_bytes5,000,000Encoded SVG source
max_svg_raster_dimension8,192SVG raster width or height
max_svg_raster_pixels16,777,216SVG raster pixel count
max_image_count1,000Images in one render
max_image_source_bytes10,000,000One encoded image
max_aggregate_image_source_bytes50,000,000Encoded images in one render
max_decoded_image_bytes40,000,000One decoded image
max_aggregate_decoded_image_bytes80,000,000Decoded images in one render
max_background_image_tiles10,000Repeated background tiles in one render
max_css_numeric_magnitude1,000,000,000Absolute CSS numeric operands and converted lengths, excluding identifiers and quoted text
max_layout_cardinality1,000Grid tracks, placements, and table spans

See render options and supported formats.

Fonts

SettingDefaultApplies to
max_font_cmap_work1,000,000Encoding records, segments, and codepoint visits prepared per TTF character map
max_font_cache_entries64Parsed font files retained by the cache
max_system_font_cache_entries64Positive and negative installed-font discovery results retained by the cache

See font configuration.

Metadata and bookmarks

SettingDefaultApplies to
max_pdf_info_value_bytes1,000,000One metadata value supplied for PDF generation or update
max_pdf_info_total_bytes5,000,000Metadata values supplied for one PDF generation or update
max_pdf_outline_items10,000Outline items read or generated for one PDF
max_pdf_outline_depth64Nested outline levels
max_pdf_outline_title_bytes16,384UTF-8 bytes in one outline title
max_pdf_outline_total_title_bytes5,000,000UTF-8 title bytes across one outline tree
max_pdf_name_tree_nodes10,000Name-tree nodes traversed for named destinations
max_pdf_named_destinations10,000Legacy and name-tree destination entries in one PDF

See metadata updates and bookmarks.

Stamping

SettingDefaultApplies to
max_stamp_text_bytes1,000,000One text/watermark input, or all generated page-number strings
max_stamp_decoded_content_bytes50,000,000Decoded stream occurrences and joining newlines across distinct overlay source pages

The text limit counts one text/watermark input or all generated page-number strings. Overlay bytes count each content-stream occurrence and joining newline across distinct source pages; reusing an overlay page does not charge its content again. See Stamping.

Merging and splitting

SettingDefaultApplies to
max_merge_inputs100PDFs in one merge
max_aggregate_merge_input_bytes100,000,000PDF bytes in one merge
max_merged_objects100,000Objects in merged output
max_merged_pages10,000Pages in merged output
max_split_outputs1,000PDFs returned by one split operation
max_split_object_writes1,000,000Aggregate objects serialized by one split operation
max_aggregate_split_output_bytes100,000,000Aggregate bytes returned by one split operation

Merge limits apply across the combined input/output. Split byte and object limits apply across all returned PDFs. See Merging and Splitting.

Text extraction

SettingDefaultApplies to
max_text_decoded_content_bytes50,000,000Decoded content used by extraction
max_text_parsed_instructions100,000Unique parsed content instructions
max_text_stream_uses100,000Content stream references traversed
max_text_instruction_uses1,000,000Aggregate content instruction work
max_text_form_expansions10,000Form XObject executions
max_text_spans25,000Extracted spans per page
max_text_layout_whitespace_bytes1,000,000Coordinate-based padding spaces reconstructed across one text extraction
max_cmap_bytes1,000,000One CMap stream
max_cmap_entries100,000Mappings in one CMap
max_cid_width_entries65,536CID width entries
max_form_xobject_depth20Form XObject nesting

Reconstructed whitespace counts added padding, not original text or page separators. It applies only to layout: true. The PDF CID range is fixed at 0 through 65,535, so max_cid_width_entries cannot exceed 65,536. See Text extraction.

Check active settings

NativeElixirPdfUtilities.Limits.defaults/0 returns built-in values. NativeElixirPdfUtilities.Limits.effective/0 returns the active configuration.