Enterprise edition: this unit ships in Lib\Enterprise and is linked by FPdfEnterprise and the PDFiumPasEnt / PDFiumLazEnt packages; see the edition matrix
TVt2sChunkKind = (vtckInlinePdf, vtckAttachmentPdf, vtckIccProfile);
TPdfVT2sChunk = record
Kind: TVt2sChunkKind;
Bytes: TBytes;
FileName: AnsiString;
end;
TPdfVT2sChunks = array of TPdfVT2sChunk;
TAnsiStrings = array of AnsiString;
TPdfVT2sValidationResult = record
Issues: TPdfVT2sValidationIssues;
function IsCompliant: Boolean;
end;
TPdfVTPrintingConditionSource = (vtpcsNone, vtpcsEmbeddedProfile, vtpcsMimeProfile);
TPdfVTPrintingConditionEvidence = record
PartIndex: Integer;
Conformance: TPdfVTConformance;
PdfXVersion: AnsiString;
OutputIntentObjectNumber: Integer;
OutputConditionIdentifier: AnsiString;
RegistryName: AnsiString;
Source: TPdfVTPrintingConditionSource;
ProfileFileName: AnsiString;
ProfileName: AnsiString;
ProfileColorSpace: AnsiString;
ProfileByteSize: Int64;
ProfileMd5: string;
ProfileSha256: string;
ProfileVersion: string;
ProfileDeviceClass: string;
ProfilePcs: string;
ProfileComponentCount: Integer;
Resolved: Boolean;
ProfileValid: Boolean;
DPart: TPdfVTDPartEvidence;
end;
TPdfVT2sValidationReport = record
Validation: TPdfVT2sValidationResult;
PrintingConditions: TPdfVTPrintingConditionEvidenceArray;
end;
procedure BuildPdfVT2sStream(const Chunks: TPdfVT2sChunks; Dest: TStream);
function ValidatePdfVT2sStream(Source: TStream): TPdfVT2sValidationResult;
function InspectPdfVT2sStream(Source: TStream): TPdfVT2sValidationReport;
FPdfPdfvtMime implements the PDF/VT-2s transport defined in ISO 16612-2 Annex, where a PDF/VT document plus its referenced reusable PDF content and ICC profile are packaged as a single MIME multipart stream
Unlike the TPdf.SaveAsPdfVT path that writes a standalone PDF/VT-1 file, this unit operates purely on byte streams and never loads pdfium.dll, so it can run in headless servers and batch pipelines
BuildPdfVT2sStream assembles the chunks in order and emits the StreamVersion header, part boundaries and per-part Content-Type / Content-Disposition headers. Blank attachment filenames raise EConvertError before any output is written; ValidatePdfVT2sStream parses an existing stream back and reports structural, printing-condition and ICC deviations as a typed issue set
InspectPdfVT2sStream returns the same compatibility result plus evidence for each PDF/VT part, including PDF/VT conformance, PDF/X base, OutputIntent identity, profile provenance, MD5 and SHA-256, raw ICC metadata and DPart page and recipient-record counts
Each PDF part is first classified with ValidatePdfVTCompliance; PDF/X-only reusable attachments remain eligible reference targets but are excluded from PDF/VT hierarchy and printing-condition comparisons
Profile packaging follows the file base: PDF/VT-1 with PDF/X-4 and PDF/VT-2 with PDF/X-5g use an embedded DestOutputProfile, whilst PDF/VT-2 with PDF/X-4p or PDF/X-5pg uses DestOutputProfileRef resolved to an earlier ICC MIME part
| Value | MIME role |
|---|---|
vtckInlinePdf | A PDF/VT document carried as an inline application/pdf part; at least one is required |
vtckAttachmentPdf | A reusable PDF content part referenced by the inline document, carried as an attachment with a filename |
vtckIccProfile | An ICC profile part (application/vnd.iccprofile) supplied as an attachment with a filename |
| Field | Meaning |
|---|---|
Kind | The TVt2sChunkKind role the part plays in the assembled stream |
Bytes | Raw payload written as the MIME part body after the part headers |
FileName | Filename emitted in the Content-Disposition filename parameter; required for the attachment kinds and ignored for inline parts |
| Type | Purpose |
|---|---|
TVt2sChunkKind | Enumerates the MIME roles an input chunk can take, as listed in the chunk kinds table |
TPdfVT2sChunk | One input part handed to BuildPdfVT2sStream, described field by field in the chunk fields table |
TPdfVT2sChunks | Dynamic array of ordered MIME chunks supplied to BuildPdfVT2sStream |
TAnsiStrings | Dynamic filename array used when validating external-file references in the inline PDF |
TPdfVT2sValidationIssues | Set of TPdfVT2sValidationIssue findings returned by validation |
TPdfVTPrintingConditionSource | Origin of the profile evidence: vtpcsNone when unresolved, vtpcsEmbeddedProfile for an embedded DestOutputProfile stream, vtpcsMimeProfile for a DestOutputProfileRef resolved from an ICC MIME part |
TPdfVTPrintingConditionEvidence | Per-part PDF/VT and PDF/X classification, OutputIntent, profile source, identity, digest, ICC header and DPart facts |
TPdfVTPrintingConditionEvidenceArray | Dynamic array of TPdfVTPrintingConditionEvidence records, one for each part classified as PDF/VT |
TPdfVT2sValidationReport | Detailed result returned by InspectPdfVT2sStream without changing the legacy result layout |
| Field | Meaning |
|---|---|
Validation | The TPdfVT2sValidationResult issue set ValidatePdfVT2sStream also returns on its own |
PrintingConditions | TPdfVTPrintingConditionEvidenceArray with one evidence record per PDF/VT part, inline or reusable attachment |
| Field | Meaning |
|---|---|
PartIndex | Zero-based ordinal of the inspected part within the whole stream, counting every MIME part |
Conformance | TPdfVTConformance level classified for the part |
PdfXVersion | pdfxid:GTS_PDFXVersion value read from the part XMP metadata, empty when absent |
OutputIntentObjectNumber | Object number of the single authoritative GTS_PDFX OutputIntent, 0 when resolution failed |
OutputConditionIdentifier | Decoded OutputConditionIdentifier string of that OutputIntent |
RegistryName | Decoded RegistryName string of that OutputIntent |
Source | Profile origin: vtpcsNone until resolution succeeds, then vtpcsEmbeddedProfile or vtpcsMimeProfile |
ProfileFileName | Filename named by the DestOutputProfileRef URL file specification, locating the ICC MIME part |
ProfileName | ProfileName string required by DestOutputProfileRef; empty when the profile is embedded |
ProfileColorSpace | Four-byte ProfileCS string from the reference, or the raw ICC header colour space signature when the profile is embedded |
ProfileByteSize | Byte length of the resolved profile as reported by the bounded ICC inspection |
ProfileMd5 | Lowercase hex MD5 digest of the complete profile bytes |
ProfileSha256 | Lowercase hex SHA-256 digest of the complete profile bytes |
ProfileVersion | Decoded ICC version string of the profile |
ProfileDeviceClass | Trimmed device class signature from the ICC header |
ProfilePcs | Trimmed profile connection space signature from the ICC header |
ProfileComponentCount | Component count derived from the ICC data colour space signature |
Resolved | True once the profile bytes were located and passed through the bounded ICC inspection |
ProfileValid | True when the ICC inspection reported no issues and the device class is prtr |
DPart | TPdfVTDPartEvidence page and recipient-record facts read from the DPartRoot |
| Value | Reported when |
|---|---|
vtmviNotMultipart | The stream is not a multipart MIME container |
vtmviMissingStreamVersion | The required PDF/VT StreamVersion header is absent |
vtmviStreamVersionValue | The StreamVersion value is not the expected 1 |
vtmviStreamVersionAfterCt | StreamVersion appears after the Content-Type line instead of before it |
vtmviMissingBoundary | The Content-Type boundary parameter is missing |
vtmviNoInlinePdf | No inline PDF/VT part is present |
vtmviInlinePdfNotPdfVT | The inline part is not declared as PDF/VT |
vtmviIccProfileBadDisposition | An ICC profile part is not an attachment |
vtmviAttachmentMissingFilename | An attachment part lacks the required filename |
vtmviInlineHasFilename | The inline PDF part carries a filename, which is not permitted |
vtmviNodeNameListMismatch | Two PDF/VT files in the stream expose different ordered lists of decoded PDF names |
vtmviRecordLevelMismatch | DPart record levels are inconsistent across the container |
vtmviForwardReference | An attachment is referenced before it appears in the stream |
vtmviBoundaryInvalidChar | The boundary string contains characters not allowed by RFC 2046 |
vtmviDuplicateFilename | Two MIME attachments expose the same case-sensitive filename |
vtmviOutputIntentAmbiguous | A PDF part has zero or multiple authoritative GTS_PDFX OutputIntents |
vtmviOutputProfilePackagingMismatch | The OutputIntent has both profile forms, neither form, or a form incompatible with the PDF/X-4, PDF/X-4p, PDF/X-5g or PDF/X-5pg base |
vtmviOutputProfileReferenceInvalid | A DestOutputProfileRef omits required metadata, a URL file specification or uses a forbidden ColorantTable |
vtmviReferencedPartWrongType | The referenced filename resolves to a MIME part that is not an ICC profile |
vtmviIccProfileInvalid | The ICC header, declared size, signature, tag table or supported process colour space is invalid |
vtmviIccChecksumMismatch | The decoded 16-byte CheckSum differs from MD5 of the complete ICC file |
vtmviIccVersionMismatch | The declared four ICCVersion bytes differ from ICC header bytes 8 through 11 |
vtmviIccColorSpaceMismatch | ProfileCS differs from ICC header bytes 16 through 19 or is not GRAY, RGB or CMYK |
vtmviIccProfileNameMismatch | ProfileName matches no valid profileDescriptionTag locale value |
vtmviPrintingConditionUnresolved | The authoritative OutputIntent, identifier or external ICC dependency cannot be resolved |
vtmviPrintingConditionMismatch | PDF/VT parts disagree on OutputConditionIdentifier, RegistryName presence or value, or process colour space |
vtmviIccDeviceClassMismatch | An embedded or external destination profile is not an output-device prtr profile |
vtmviMalformedMultipart | The multipart headers are incomplete or the closing delimiter is missing, so the container body cannot be walked |
vtmviPdfBadDisposition | An application/pdf part has no inline or attachment disposition |
vtmviInputLimitExceeded | The MIME input exceeds 256 MiB and was rejected before its body was read |
ValidatePdfVT2sStream on any stream produced by BuildPdfVT2sStream round-trip testing or on externally authored PDF/VT-2s containers before processingTPdfVT2sValidationResult.IsCompliant returns True only when the Issues set is empty
var Chunks: TPdfVT2sChunks;
begin
SetLength(Chunks, 2);
Chunks[0].Kind := vtckIccProfile;
Chunks[0].FileName := 'profile.icc';
Chunks[0].Bytes := IccBytes;
Chunks[1].Kind := vtckInlinePdf;
Chunks[1].Bytes := InlinePdfBytes;
BuildPdfVT2sStream(Chunks, MimeStream);
end;