PDFium Delphi Component Docs

FPdfPdfvtMime unit

Enterprise edition: this unit ships in Lib\Enterprise and is linked by FPdfEnterprise and the PDFiumPasEnt / PDFiumLazEnt packages; see the edition matrix

Unit: FPdfPdfvtMime
Builds and validates single-file PDF/VT-2s MIME part streams that carry an inline PDF/VT document, its reusable attachment payload, and the ICC profile as one multipart container

Syntax

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;

Description

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, while PDF/VT-2 with PDF/X-4p or PDF/X-5pg uses DestOutputProfileRef resolved to an earlier ICC MIME part

Chunk kinds

ValueMIME role
vtckInlinePdfA PDF/VT document carried as an inline application/pdf part; at least one is required
vtckAttachmentPdfA reusable PDF content part referenced by the inline document, carried as an attachment with a filename
vtckIccProfileAn ICC profile part (application/vnd.iccprofile) supplied as an attachment with a filename

Chunk fields

FieldMeaning
KindThe TVt2sChunkKind role the part plays in the assembled stream
BytesRaw payload written as the MIME part body after the part headers
FileNameFilename emitted in the Content-Disposition filename parameter; required for the attachment kinds and ignored for inline parts

Supporting types

TypePurpose
TVt2sChunkKindEnumerates the MIME roles an input chunk can take, as listed in the chunk kinds table
TPdfVT2sChunkOne input part handed to BuildPdfVT2sStream, described field by field in the chunk fields table
TPdfVT2sChunksDynamic array of ordered MIME chunks supplied to BuildPdfVT2sStream
TAnsiStringsDynamic filename array used when validating external-file references in the inline PDF
TPdfVT2sValidationIssuesSet of TPdfVT2sValidationIssue findings returned by validation
TPdfVTPrintingConditionSourceOrigin of the profile evidence: vtpcsNone when unresolved, vtpcsEmbeddedProfile for an embedded DestOutputProfile stream, vtpcsMimeProfile for a DestOutputProfileRef resolved from an ICC MIME part
TPdfVTPrintingConditionEvidencePer-part PDF/VT and PDF/X classification, OutputIntent, profile source, identity, digest, ICC header, and DPart facts
TPdfVTPrintingConditionEvidenceArrayDynamic array of TPdfVTPrintingConditionEvidence records, one for each part classified as PDF/VT
TPdfVT2sValidationReportDetailed result returned by InspectPdfVT2sStream without changing the legacy result layout

Report fields

FieldMeaning
ValidationThe TPdfVT2sValidationResult issue set ValidatePdfVT2sStream also returns on its own
PrintingConditionsTPdfVTPrintingConditionEvidenceArray with one evidence record per PDF/VT part, inline or reusable attachment

Evidence fields

FieldMeaning
PartIndexZero-based ordinal of the inspected part within the whole stream, counting every MIME part
ConformanceTPdfVTConformance level classified for the part
PdfXVersionpdfxid:GTS_PDFXVersion value read from the part XMP metadata, empty when absent
OutputIntentObjectNumberObject number of the single authoritative GTS_PDFX OutputIntent, 0 when resolution failed
OutputConditionIdentifierDecoded OutputConditionIdentifier string of that OutputIntent
RegistryNameDecoded RegistryName string of that OutputIntent
SourceProfile origin: vtpcsNone until resolution succeeds, then vtpcsEmbeddedProfile or vtpcsMimeProfile
ProfileFileNameFilename named by the DestOutputProfileRef URL file specification, locating the ICC MIME part
ProfileNameProfileName string required by DestOutputProfileRef; empty when the profile is embedded
ProfileColorSpaceFour-byte ProfileCS string from the reference, or the raw ICC header colour space signature when the profile is embedded
ProfileByteSizeByte length of the resolved profile as reported by the bounded ICC inspection
ProfileMd5Lowercase hex MD5 digest of the complete profile bytes
ProfileSha256Lowercase hex SHA-256 digest of the complete profile bytes
ProfileVersionDecoded ICC version string of the profile
ProfileDeviceClassTrimmed device class signature from the ICC header
ProfilePcsTrimmed profile connection space signature from the ICC header
ProfileComponentCountComponent count derived from the ICC data colour space signature
ResolvedTrue once the profile bytes were located and passed through the bounded ICC inspection
ProfileValidTrue when the ICC inspection reported no issues and the device class is prtr
DPartTPdfVTDPartEvidence page and recipient-record facts read from the DPartRoot

Validation issues

ValueReported when
vtmviNotMultipartThe stream is not a multipart MIME container
vtmviMissingStreamVersionThe required PDF/VT StreamVersion header is absent
vtmviStreamVersionValueThe StreamVersion value is not the expected 1
vtmviStreamVersionAfterCtStreamVersion appears after the Content-Type line instead of before it
vtmviMissingBoundaryThe Content-Type boundary parameter is missing
vtmviNoInlinePdfNo inline PDF/VT part is present
vtmviInlinePdfNotPdfVTThe inline part is not declared as PDF/VT
vtmviIccProfileBadDispositionAn ICC profile part is not an attachment
vtmviAttachmentMissingFilenameAn attachment part lacks the required filename
vtmviInlineHasFilenameThe inline PDF part carries a filename, which is not permitted
vtmviNodeNameListMismatchTwo PDF/VT files in the stream expose different ordered lists of decoded PDF names
vtmviRecordLevelMismatchDPart record levels are inconsistent across the container
vtmviForwardReferenceAn attachment is referenced before it appears in the stream
vtmviBoundaryInvalidCharThe boundary string contains characters not allowed by RFC 2046
vtmviDuplicateFilenameTwo MIME attachments expose the same case-sensitive filename
vtmviOutputIntentAmbiguousA PDF part has zero or multiple authoritative GTS_PDFX OutputIntents
vtmviOutputProfilePackagingMismatchThe 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
vtmviOutputProfileReferenceInvalidA DestOutputProfileRef omits required metadata, a URL file specification, or uses a forbidden ColorantTable
vtmviReferencedPartWrongTypeThe referenced filename resolves to a MIME part that is not an ICC profile
vtmviIccProfileInvalidThe ICC header, declared size, signature, tag table, or supported process colour space is invalid
vtmviIccChecksumMismatchThe decoded 16-byte CheckSum differs from MD5 of the complete ICC file
vtmviIccVersionMismatchThe declared four ICCVersion bytes differ from ICC header bytes 8 through 11
vtmviIccColorSpaceMismatchProfileCS differs from ICC header bytes 16 through 19 or is not GRAY, RGB, or CMYK
vtmviIccProfileNameMismatchProfileName matches no valid profileDescriptionTag locale value
vtmviPrintingConditionUnresolvedThe authoritative OutputIntent, identifier, or external ICC dependency cannot be resolved
vtmviPrintingConditionMismatchPDF/VT parts disagree on OutputConditionIdentifier, RegistryName presence or value, or process colour space
vtmviIccDeviceClassMismatchAn embedded or external destination profile is not an output-device prtr profile
vtmviMalformedMultipartThe multipart headers are incomplete or the closing delimiter is missing, so the container body cannot be walked
vtmviPdfBadDispositionAn application/pdf part has no inline or attachment disposition
vtmviInputLimitExceededThe MIME input exceeds 256 MiB and was rejected before reading its body

Remarks

Example

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;

See Also

FPdfAsn1