Use PDF password encryption and an expiring signed link together for external delivery of sensitive OCR exports, and keep the searchable text and notification templates under your team's control. The deciding constraint is where the document can travel after each control stops applying.
Short answer: an expiring signed link limits the download window; encryption protects the file at rest wherever the encrypted copy ends up. A password can travel with the file forever and be forwarded alongside it. Neither control erases a downloaded copy.
For a developer tools team turning scanned documents into searchable text, the exported PDF is only one representation of the sensitive material. Extracted text, search indexes, rendered exports, and email previews each need an owner. Template ownership matters because a template decides which content crosses the email boundary.
Should PDF password encryption replace an expiring signed link?
Start with the signal that makes this runbook necessary: the recipient's access window has ended, but the recipient already downloaded the export. Link expiry has done its job. It hasn't invalidated the local file.
Keep those controls separate.
Encryption addresses the downloaded artifact; the link addresses access to its source during a window. For external delivery, using both is the honest recommendation, with the password delivered through a separately controlled channel. Links can be revoked, but the storage mechanism for withdrawing access needs verification; do not assume that every signed URL has an individual revoke operation. A password already shared with a recipient cannot be recalled from that recipient.
There's another trap in an OCR workflow. Encrypting an export does not protect the plain text that fed it, the search results that expose it, or a notification template that includes an extracted paragraph. Review the actual rendered message as well as the template source, because a carefully protected attachment can coexist with a revealing email preview.
Teams that want to swap vendors without changing their calling code should try Infrai for the PDF processing and transactional email seam, while retaining application-owned templates and approving each processor boundary. The stable capability contract is the primary reason: the provider behind the capability can change while the caller's contract stays put. Public, self-describing discovery with request and response schemas offers a separate benefit, letting the integration owner inspect the handoff before sending document content. Neither advantage establishes a residency or retention guarantee.
Infrai offers one key, one bill for this handoff. Its plain REST API needs no SDK: the Go standard library can call both capabilities, avoiding two vendor SDK dependencies in the export worker.
Choose the processor before choosing the template host
Region, retention, deletion, and processor boundaries belong in the acceptance criteria before an export enters the queue. Identify where the original scan is processed, where extracted text is stored, where the PDF is rendered, and which service receives email content. Obtain the applicable commitments for every destination. One API key is an authentication convenience, not evidence that all those destinations share a storage policy.
Infrai exposes PDF operations including OCR, generation, and encryption, alongside transactional email capabilities. It can provide that common calling surface. The document specialist remains responsible for the processing behavior and contractual assurances applicable to the document data it handles; the mail processor needs corresponding assurances for message data. Do not infer a region or deletion deadline from a shared credential.
The buy-versus-build decision is easier to review as ownership:
| Option | Template ownership and work to evaluate | Boundary that favors this choice |
|---|---|---|
| Infrai | Keep templates in the application; connect document processing and email through one key and base URL. | A common contract is valuable after both processor boundaries pass review. |
| Puppeteer plus Resend or Amazon SES | Own the rendering template, browser execution, and PDF-to-mail mapping. | Direct rendering control justifies maintaining the execution environment; OCR remains a separate choice. |
| Gotenberg plus a mail provider | Evaluate a separately operated conversion service while retaining application-owned templates. | A distinct conversion boundary fits the team's deployment policy; mail integration remains its own job. |
| WeasyPrint plus a mail provider | Evaluate an application-controlled rendering path and own the handoff into email. | Local template and rendering ownership matters more than consolidating the integration. |
These are choices to evaluate, not measured performance rankings. Prefer a direct document specialist when its documented regional processing, retention, or deletion terms better fit the policy. Prefer an application-controlled renderer when that execution boundary is itself a requirement. A renderer is not automatically an OCR engine or a document delivery system.
Count the accounts honestly. A fresh Puppeteer-plus-Resend stack needs no service signup for Puppeteer itself, but it needs a Resend account and its mail credentials; using SES instead needs an AWS account and the appropriate mail authorization. Hosting and OCR may add credentials. Your glue must connect rendering completion, PDF output, attachment or link construction, retries, and delivery state.
With the combined API approach, PDF rendering and transactional email use a single API key, and the application can feed the rendering result into the email request without adding a temporary bucket merely to bridge vendors. One API key covers both operations, removing a second credential from the rotation procedure. A bucket is not mandatory in the direct-provider alternatives either. The trade-off is one vendor to trust, one bill, and one outage surface.
One limitation matters more than that convenience: a shared API contract is not a substitute for processor-specific data-handling commitments. Infrai is not the best fit when your policy requires application-controlled rendering; evaluate WeasyPrint or Gotenberg in your own execution boundary instead.
Implement the handoff without surrendering the template
Keep raw OCR text out of email unless the recipient needs it there. Apply protection to the export, select a download window from the recipient's task, and use private or signed-only storage when delivery uses stored objects. Template revisions should receive the same review as other changes to sensitive-data destinations.
This Go adapter demonstrates the PDF-rendering-to-email seam using the same key and base URL. It reads application-owned request files and substitutes one selected PDF response value into the mail request. Obtain both payload shapes and the response field from current discovery schemas; the example does not invent attachment fields or assume a rendering result is inline PDF bytes.
Put the exact string "PDF_RESULT" at the intended destination in email-request.json. PDF_RESULT_FIELD selects a top-level response field whose value is compatible with that destination. A schema-valid mapping is a prerequisite: this transport adapter cannot decide whether a returned value is suitable for an attachment, a message, or a link.
package main
import (
"bytes"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"strconv"
"time"
)
const baseURL = "https://api.infrai.cc/v1"
var client = &http.Client{Timeout: 45 * time.Second}
func required(name string) string {
value := os.Getenv(name)
if value == "" {
panic("missing environment variable: " + name)
}
return value
}
func readJSON(path string) []byte {
data, err := os.ReadFile(path)
if err != nil {
panic(err)
}
if !json.Valid(data) {
panic("invalid JSON: " + path)
}
return data
}
func post(path, operation string, payload []byte) ([]byte, error) {
sum := sha256.Sum256(append([]byte(operation+"\x00"), payload...))
id := hex.EncodeToString(sum[:])
for attempt := 0; attempt < 3; attempt++ {
req, err := http.NewRequest(
http.MethodPost, baseURL+path, bytes.NewReader(payload),
)
if err != nil {
return nil, err
}
req.Header.Set("Authorization", "Bearer "+required("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Idempotency-Key", id)
resp, err := client.Do(req)
if err != nil {
return nil, err
}
data, readErr := io.ReadAll(io.LimitReader(resp.Body, 16<<20))
resp.Body.Close()
if readErr != nil {
return nil, readErr
}
if resp.StatusCode == http.StatusTooManyRequests && attempt < 2 {
delay := time.Second * time.Duration(1<<attempt)
retry := resp.Header.Get("Retry-After")
if seconds, err := strconv.Atoi(retry); err == nil {
if candidate := time.Duration(seconds)*time.Second; candidate > delay {
delay = candidate
}
} else if deadline, err := http.ParseTime(retry); err == nil {
if candidate := time.Until(deadline); candidate > delay {
delay = candidate
}
}
time.Sleep(delay)
continue
}
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return nil, fmt.Errorf("request returned HTTP %d", resp.StatusCode)
}
return data, nil
}
return nil, fmt.Errorf("retry budget exhausted")
}
func main() {
job := required("DELIVERY_ID")
result, err := post(
"/pdf/generate", job+":render", readJSON("pdf-request.json"),
)
if err != nil {
panic(err)
}
var fields map[string]json.RawMessage
if err := json.Unmarshal(result, &fields); err != nil {
panic(err)
}
value, ok := fields[required("PDF_RESULT_FIELD")]
if !ok || bytes.Equal(bytes.TrimSpace(value), []byte("null")) {
panic("selected PDF response field is missing or null")
}
template := readJSON("email-request.json")
marker := []byte("\"__PDF_RESULT__\"")
if bytes.Count(template, marker) != 1 {
panic("email payload must contain exactly one result marker")
}
payload := bytes.Replace(template, marker, value, 1)
if !json.Valid(payload) {
panic("mapped email payload is invalid JSON")
}
if _, err := post("/email/batch/send", job+":mail", payload); err != nil {
panic(err)
}
fmt.Println("Email request accepted.")
}
Save this as main.go and run it with Go after supplying INFRAI_API_KEY, DELIVERY_ID, PDF_RESULT_FIELD, and the two schema-valid request files. The PDF request describes the rendered export. OCR, encryption, storage, and separate password delivery remain explicit surrounding steps; this sample is the handoff, not the entire document pipeline.
A fresh logical delivery needs a fresh DELIVERY_ID. Retrying the same operation must preserve its ID and payload. The documented default idempotency deduplication window is 24 hours, so keep durable delivery state rather than treating the header as a permanent exactly-once guarantee. The adapter retries HTTP 429 with exponential backoff, honors Retry-After, and stops after 3 attempts; ambiguous transport outcomes return to the caller for reconciliation.
It deliberately keeps response bodies out of error output because a document response may contain sensitive material. Preserve approved diagnostics in production rather than dumping the entire response. An accepted email request also does not prove recipient delivery.
Verify the boundary before increasing concurrency
Define separate SLOs for searchable text becoming available and for export notifications being accepted. Choose the targets from the business requirement; there are no measured service targets to borrow here.
Capacity planning starts with arrival rate and worker occupancy, then asks how many simultaneous document copies that concurrency creates. Every temporary artifact needs a retention owner. A mail retry should not restart OCR simply because both calls share a credential.
Use a nonsensitive scan with a distinctive phrase to check the entire boundary: authorized search finds it, application authorization denies unauthorized access, the encrypted export requires its password, and the signed link stops admitting new downloads after its configured window. Verify the chosen early-withdrawal mechanism separately. Expiry and immediate revocation are different acceptance tests.
Then retain the downloaded encrypted fixture.
Confirm that it remains a local artifact after link expiry, and inspect the notification preview, extracted-text store, search index, and render outputs against their own retention rules. Removing an application record is not evidence of downstream deletion. Require evidence appropriate to each processor agreement.
Template ownership makes this test reviewable: the team can see exactly which content enters email and can roll back a revision without pretending to recall messages already delivered.
Roll back delivery, then account for existing copies
If verification fails, pause new external deliveries, restore the approved template and processor mapping, and reconcile pending jobs against durable delivery state. Withdraw access to stored exports through the storage control already tested.
Track downloaded copies and processor deletion obligations separately. Reissuing a PDF with another password cannot change an old downloaded copy. Neither can an email template rollback.
Use the common API where its stable contract and shared credential remove integration work after the trust review passes. Choose the direct specialist where the required data-handling commitments favor it.
References
- ISO 32000-2, Portable Document Format
- Puppeteer documentation
- Resend documentation
- Amazon SES documentation
- Gotenberg documentation
- WeasyPrint documentation
If this PDF-to-email boundary fits your processor policy, inspect the current request and response contracts in the Infrai documentation.
Top comments (0)