Generates the official PDF certificate after an artwork passes verification. This certificate is required before artwork can be listed for sale on the platform. Call this after `isCanvasSigned()` confirms the canvas signature and `image_phash()` has stored the artwork's fingerprint.
For batch certification of multiple artworks, pass a shared database connection via the `cn` parameter to avoid connection overhead.
Usage
renderCertificate(
artist,
artwork,
which_templ = NULL,
which_frame = NULL,
outdir = NULL,
new_utc = NULL,
saveDB = FALSE,
saveCDN = FALSE,
clean = TRUE,
cn = NULL
)Arguments
- artist
Character. The artist's UUID (format: `746bxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`). Obtain from `artutils::get_artist_by_slug()` or the `artist_uuid` column in artist queries. Identifies which artist's artwork is being certified.
- artwork
Character. The artwork's UUID (format: `99xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`). The `99` prefix indicates platform-authenticated artworks. Obtain from artwork queries or `artutils::genArtworkID()` for new uploads.
- which_templ
Integer. Certificate template design number (1 to 9). Each number corresponds to a different visual design stored on CDN. If NULL (default), randomly selected for variety across certificates.
- which_frame
Integer. Certificate frame style number (1 to 20). Determines the decorative border around the artwork image. If NULL (default), randomly selected.
- outdir
Character. Output directory for generated files. Must be an empty directory or non-existent (will be created). Defaults to a temp directory if NULL. Use for custom output locations or to inspect intermediate files.
- new_utc
POSIXct. Timestamp in UTC timezone for the certificate. Use `Sys.time()` for current time or a specific POSIXct value for backdating corrections. Displayed on the certificate and stored in database.
- saveDB
Logical. Whether to persist the certificate record to the database. When TRUE, requires valid database credentials via environment variables. When FALSE (default), generates certificate without database side effects - useful for previewing or testing before final generation.
- saveCDN
Logical. Whether to upload the PDF and JPEG to CDN. When TRUE, certificate becomes publicly accessible at the returned URL. When FALSE (default), files remain in local `outdir` only.
- clean
Logical. Whether to remove intermediate files (LaTeX source, template images) after rendering. Default TRUE keeps output directory clean. Set FALSE to inspect intermediate files for debugging or custom post-processing.
- cn
Database connection object (class `PqConnection` from {RPostgres}). If NULL (default), creates a new connection via `artcore::dbc()` and closes it on function exit. Pass an existing connection for batch operations to avoid repeated connection overhead. Caller responsible for closing passed connections.
Value
data.table with certificate details:
- artist_uuid
Artist identifier
- art_uuid
Artwork identifier
- cert_id
Formatted certificate ID (e.g., "000-000-123")
- template_id
Template number used
- frame_id
Frame number used
- created_utc
Certificate creation timestamp
- path_pdf
CDN URL to PDF certificate
- path_jpeg
CDN URL to JPEG preview
Details
Certificate generation requires: - Valid artist/artwork UUIDs with verification record in database - LaTeX installation (tinytex/lualatex) - CDN access for template/frame assets
The function: 1. Retrieves artwork metadata from database 2. Downloads template and frame assets from CDN 3. Composites framed artwork image 4. Renders LaTeX template with artwork data 5. Generates PDF and JPEG outputs 6. Optionally saves to database and uploads to CDN
Examples
if (FALSE) { # \dontrun{
# Generate certificate without saving
cert <- renderCertificate(
artist = "artist-uuid-here",
artwork = "artwork-uuid-here"
)
# Generate and persist to database/CDN
cert <- renderCertificate(
artist = "artist-uuid-here",
artwork = "artwork-uuid-here",
saveDB = TRUE,
saveCDN = TRUE
)
# Use specific template and frame
cert <- renderCertificate(
artist = "artist-uuid-here",
artwork = "artwork-uuid-here",
which_templ = 1,
which_frame = 3
)
} # }
