Requires Small Business or Enterprise since 3.266.0; link FPdfSmallBusiness and remove any stale Lib\Enterprise\FPdfPdfrEngine.pas during manual upgrades
function SaveAsPdfR(const FileName: string): Boolean; overload;
function SaveAsPdfR(const FileName: string; const Options: TPdfRSaveOptions): Boolean; overload;
SaveAsPdfR performs the regular SaveAs first, then writes a
single complete revision that attaches PDF/R-1 file-format markers.
ISO 23504-1 6.7 forbids incremental updates except for digital
signatures, so the final cross-reference table lists every live
object and carries no /Prev entry. PDF/R-1
(ISO 23504-1:2020) is the strict raster-image transport subset of
PDF used by the TWAIN Working Group for scanned document workflows;
it carries a fixed-size raster buffer per page, supports bitonal /
greyscale / RGB images and FlateDecode / CCITTFaxDecode / DCTDecode
compression only
The post-processing injects five classes of bytes into the saved stream:
%PDF-raster-1.0 version-identification comment, written between the trailer dictionary and the startxref keyword (ISO 23504-1 §5). This is unique to PDF/R — the other PDF/x standards identify themselves through XMP and Info-dictionary entries insteadThe output stays byte-identical to the base SaveAs result up to
the end of the original PDF; the new objects are appended and the
final cross-reference section is rebuilt as one complete table
(and the source catalog / Info are replaced with stripped
versions via same-object-number rewriting). The two overloads
differ only in how the configuration is passed in: the file-name-
only form uses TPdfRSaveOptions.Default with
auto-population of the four Info fields and DocumentId from
FPDF_GetMetaText / FPDF_GetFileIdentifier
An unencrypted source saved under a %PDF-2.0 header has
that header rewritten to %PDF-1.7: §6.2.2 admits only
%PDF-1.4 through %PDF-1.7 and §6.2.3
reserves 2.0 for an encrypted file, so a 2.0 header cannot survive a
conversion into PDF/R. The header line is a fixed eight bytes, so
rewriting it in place leaves every recorded object offset valid. An
encrypted source is copied through unchanged (it must keep 2.0), and a
signed source keeps its bytes untouched because its signature covers the
header
Returns True on success
[0 0 w h], only FlateDecode / CCITTFaxDecode (bitonal) / DCTDecode (8-bit grey or RGB) filters are allowed, no object streams, every indirect reference must have generation number zero, and each page is built from one or more raster strips. PDFium-generated documents that already match this pattern (e.g. scanner output passed through PDFium for repackaging) work well; arbitrary content-rich PDFs typically do notTPdfRSaveOptions.StripCatalogOptionalEntries and StripInfoOptionalEntries default to True; set them False if you want the injector to preserve all source entries (the output then won't meet §6.3 / §6.4.3 but the version marker and XMP are still attached)%PDF-2.0 header and the Standard security handler at /V 5 and /R 6 (AES-256). PDFium-generated PDFs use a 1.x header so encrypted output isn't a PDF/R-1 candidate without further re-saving
// Simple PDF/R-1 output; only meaningful when the source PDF is
// already a raster scan (one image per page, allowed filters only).
if Pdf1.SaveAsPdfR('C:\Scan.pdfr.pdf') then
ShowMessage('Saved with PDF/R-1 markers');
// Validate to see whether structural rules are also satisfied
Pdf1.FileName := 'C:\Scan.pdfr.pdf';
Pdf1.Active := True;
if Pdf1.ValidatePdfR.IsCompliant then
ShowMessage('PDF/R-1 conformant');