PDFium Delphi Component Docs

FPdfPdfvtMime unit

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; 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

Supporting types

TypePurpose
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
TPdfVT2sValidationReportDetailed result returned by InspectPdfVT2sStream without changing the legacy result layout

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 NodeNameList values
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

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