---
title: Retrieve a cached PDF image
summary: Retrieve a cached PDF page image, waiting for the server to render it if necessary.
status: draft
owner: SAIF.Core Documentation Team
last_reviewed: 2026-09-24
library: SAIF.Services.Web.Proxies
reference_type: package
operation_id: OP-WP-05
trigger: A caller request; no in-repository caller constructs PdfServiceProxy
---

# Retrieve a cached PDF image

`PdfServiceProxy.GetImage` wraps the PDFService WCF client (`PDFServiceClient`) to request a cached image by sequence number, asking the remote service to render and cache it immediately, and waiting through a bounded retry loop if it is not yet ready.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-WP-05 |
| **Trigger** | A caller request; no in-repository code constructs this wrapper |
| **Inputs** | `long imageSeqNum`, `int maxWaitTimeInSeconds = 10` |
| **Outputs** | Image bytes |
| **Primary components** | `PdfServiceProxy.GetImage` |
| **Entry point** | `Services/SAIF.Services.Web.Proxies/PDFServiceProxy.cs` |

## Steps

1. Construct `PdfServiceProxy(serviceUrl, database)`: guard both arguments ([WP-BR-001](../business-rules.md#wp-br-001-required-arguments-must-be-non-null-or-non-empty)), then build a `BasicHttpBinding` with `int.MaxValue` quotas; `database` is stored as the data environment.
2. **`GetImage(imageSeqNum, maxWaitTimeInSeconds)`:** build a `PDFCacheArgs` ([WP-BR-011](../business-rules.md#wp-br-011-pdf-image-retrieval-requests-immediate-caching-with-retry)):
   - `ImageSeqNum = imageSeqNum`
   - `DataEnvironment = database`
   - `CachePriority = 10000` ("retrieve, process and cache immediately")
   - `DataUser = "IMG"` (a pool code, not a schema)
   - `WaitCacheEnabled = true`
   - `WaitCacheRetryAttempts = maxWaitTimeInSeconds` (default 10)
   - `WaitCacheRetryInterval = 1000` ms
3. Call wire `LoadCache(args)` and return `result.File` as bytes.
   - On failure: a null `result` returned by the wire call throws `NullReferenceException`.

## Process flow

The following diagram visualizes the cache-and-retry request.

```mermaid
flowchart TD
	Start([GetImage invoked]) --> Build["Build PDFCacheArgs<br>(priority 10000, retry n times)"]
	Build --> Call["Call wire LoadCache(args)"]
	Call --> Check{result null?}
	Check -->|Yes| Fail([NullReferenceException])
	Check -->|No| Ret([Return result.File as bytes])
```

## Failure and edge-case behavior

- A null/empty `serviceUrl` or `database` at construction throws an argument exception before any wire client is created.
- A null `result` from `LoadCache` throws `NullReferenceException`; there is no null guard on the wire response.
- The wait/retry behavior is delegated entirely to the remote PDF service via `PDFCacheArgs`; this wrapper implements no client-side retry loop of its own.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- `Services/SAIF.Services.Web.Proxies/PDFServiceProxy.cs`
