---
name: kimaai_embedding_pdf_max_bytes
type: filter
since: 1.6.0
tier: premium
feature: embeddings
area: embedding-search
summary: Changes the largest PDF, in bytes, that is read for the knowledge base.
parameters:
  - name: max_bytes
    type: int
    description: The limit, 20 MB (20971520 bytes) by default.
  - name: attachment
    type: WP_Post
    description: The PDF's attachment post.
returns:
  type: int
  description: The limit in bytes.
---

# kimaai_embedding_pdf_max_bytes

## When it fires

In a sync of the knowledge base, for each PDF, before its file is read. A PDF larger than the limit is not read: the sync records the error "PDF is larger than the limit" for it and goes on with the next post.

The whole file is read and parsed in PHP's memory, so the limit protects the sync from running out of memory. Before you raise it, make sure PHP's `memory_limit` leaves room for a file several times that size; a sync that runs out of memory stops for every post after it.

## Example

```php
add_filter(
  'kimaai_embedding_pdf_max_bytes',
  function (int $max_bytes): int {
    // The product manuals are up to 50 MB; the server has the memory for them.
    return 50 * 1024 * 1024;
  }
);
```

## Related

- `kimaai_embedding_pdf_extracted_text`: changes the text read from a PDF.
- `kimaai_embedding_supported_sources`: the sources a sync can index, PDFs among them.
