ConvertPdfDocumentColours는 현재 활성 PDF 리비전을 읽고 원본 성분 피연산자와 이미지 샘플을 IPdfColourTransform으로 변환해 별도 출력 스트림에 일관된 리비전을 추가합니다
DeviceGray, DeviceRGB, DeviceCMYK, ICCBased 공간의 텍스트와 벡터 채우기/선 연산자, 상속된 페이지 리소스, 명명된 기본 색 공간 별칭, 중첩 Form XObject, 8비트/16비트 성분의 raw 또는 일반 필터 이미지를 지원합니다
콘텐츠 배열은 스트림 사이에 공백을 두고 하나의 피연산자 파서와 그래픽 상태 스택을 공유합니다. 변환 중에도 q/Q, 기본 색 공간, 성분 수는 원본 색 공간에 연결된 상태를 유지합니다
CMYK 피연산자는 PDF 콘텐츠 및 이미지 스트림에서 가져오며 렌더링된 RGB getter는 사용하지 않습니다. 프로파일 없는 DeviceCMYK에는 DeviceCMYKProfile을 지정하세요
원본 ICCBased 프로파일은 원래 리소스 범위에서 해석합니다. /Range [0 1 ...]가 없거나 기본값인 경우만 지원하며 이미지 /Decode 배열은 변환 전에 적용한 다음 변환된 이미지에서 제거합니다
16비트 이미지 샘플은 PDF 빅엔디언 순서를 유지합니다. 샘플 할당 전에 정확한 바이트 지오메트리와 출력 확장량을 검사하며 stride나 패딩 바이트를 만들어 넣지 않습니다
PreserveAllSpotColours의 기본값은 true입니다. false라면 디코딩한 PDF 색재 이름을 PreservedSpotColours에 지정하세요. Separation 또는 DeviceN은 모든 색재가 선택된 경우에만 유지합니다
유지할 별색의 연산자, 농도 함수, 리소스는 그대로 둡니다. 선택하지 않은 별색에는 전용 변환 백엔드가 필요하며 지원하지 않는 것으로 보고합니다
이미지 stencil mask와 참조된 mask 데이터는 유지합니다. color-key mask, 명시적 mask, soft-mask matte 성분에는 별도 정책이 필요합니다
원본 성분 디코더가 없는 DCT/JPX 이미지, 1/2/4비트 이미지와 행 패딩, 기본값 아닌 ICC 범위, Indexed/Cal/Lab/Pattern 공간, inline image, shading 함수, Type3 glyph program, 주석 사전의 색상, 폼 기본 외관 명령, XFA 색상 콘텐츠, 투명 그룹, 비정상 blend, overprint, 그래픽 transfer 함수나 rendering intent는 지원하지 않습니다
자체 리소스를 가진 Form은 성분만 있는 sc/scn 앞에 색 공간을 설정해야 합니다. 상속한 원본 컨텍스트가 다른 공유 Form이나 이미지는 지원하지 않는 것으로 보고하고 캐시된 실패를 호출한 모든 범위로 전파합니다
FailOnUnsupported의 기본값은 true이며 실패 시 출력 대상을 유지합니다. false로 설정하면 지원되는 독립적 갱신은 허용하지만 Complete는 false가 되고 부분 변환에 새 OutputIntent를 쓰지 않습니다
부분 결과에는 원본의 기존 OutputIntent가 남을 수 있습니다. OutputIntentWritten은 이번 작업이 새로운 출력 선언을 설치했는지 나타냅니다
완전한 결과에는 지정한 출력 ICC 프로파일을 삽입하고 요청한 식별자로 OutputIntent를 씁니다. PDF/X, PDF/A 또는 다른 적합성 수준을 인증하는 것은 아닙니다
원본과 출력은 서로 다른 스트림이어야 합니다. 원본 위치를 복원하고 준비 단계의 실패는 출력에 영향을 주지 않으며 취소는 EPdfOperationCancelled를 유지합니다
준비한 결과는 출력 스트림 API로 대상 내용을 교체합니다. 대상 잘라내기나 쓰기 중 예외는 부분 출력을 남길 수 있으므로 원자적 파일 공개가 필요하면 임시 파일에 쓰고 성공 후 rename하세요
암호화나 기존 서명이 있다면 별도로 암호화되지 않고 서명 없는 원본을 준비해야 합니다. 증분 색상 변환은 서명 유효성을 유지하지 않습니다
기본 상한은 디코딩한 콘텐츠/이미지 스트림마다 64 MiB, 출력 준비 512 MiB, 문제 보고 10,000개, 깊이 64이며 활성 객체 리더의 상한도 적용됩니다
갱신을 누적하기 전에 원본 바이트, 준비된 교체 객체, 예약한 xref/trailer 여유를 보수적으로 계산합니다. 직렬화 전에 전체 trailer 길이를 포함하며 제한된 출력 스트림은 논리 크기를 늘리기 전에 상한 초과 쓰기를 거부합니다
이 제한은 출력 준비의 논리 크기에 적용되며 프로세스 전체 메모리나 메모리 할당기의 용량 반올림을 제한하지는 않습니다. 공개 전에 최종 직렬화 크기를 다시 검사합니다
실제 RGB, CMYK, ICCBased 이미지 변환, 텍스트/벡터 변환, 중첩 Form, Separation/DeviceN 유지, OutputIntent, 압축 object stream, PDF 저장/재열기/렌더링을 Delphi와 FPC의 Win32/Win64에서 검증했습니다
ProviderOptions := TPdfLittleCmsOptions.Default; Provider := CreatePdfLittleCmsColourTransform(LibraryPath, ProviderOptions); Options := TPdfDocumentColourOptions.Default; Options.DeviceCMYKProfile := SourceCmykProfile; TargetProfile := CreatePdfLittleCmsGrayProfile(LibraryPath); if not ConvertPdfDocumentColours(Source, Destination, pcsDeviceGray, TargetProfile, Provider, Options, Report, CancellationToken) then raise Exception.Create(Report.ErrorText);
type
TPdfSpotColourNames = array of AnsiString;
TPdfDocumentColourOptions = record
ReadOptions: TPdfActiveObjectReadOptions;
MaxDecodedStreamBytes: Integer;
MaxOutputBytes: Int64;
MaxIssues: Integer;
MaxDepth: Integer;
FailOnUnsupported: Boolean;
PreserveAllSpotColours: Boolean;
PreservedSpotColours: TPdfSpotColourNames;
DeviceGrayProfile, DeviceRGBProfile, DeviceCMYKProfile: TBytes;
OutputIntentIdentifier: string;
class function Default: TPdfDocumentColourOptions; static;
end;
TPdfDocumentColourIssue = record
ObjectNumber: Integer;
Reason: string;
end;
TPdfDocumentColourIssues = array of TPdfDocumentColourIssue;
TPdfDocumentColourReport = record
Succeeded: Boolean;
Complete: Boolean;
ContentStreamsConverted, FormsConverted, ImagesConverted: Integer;
ColourOperatorsConverted, PreservedSpotSelections, PreservedMasks: Integer;
UnsupportedCount: Integer;
OutputIntentWritten: Boolean;
Issues: TPdfDocumentColourIssues;
ErrorText: string;
end;
function ConvertPdfDocumentColours(Source, Destination: TStream;
TargetSpace: TPdfColourSpace; const TargetProfile: TBytes;
Transform: IPdfColourTransform; const Options: TPdfDocumentColourOptions;
out Report: TPdfDocumentColourReport;
CancellationToken: IPdfCancellationToken = nil): Boolean;