|
Preflight Cookbook
이 쿡북은 preflight API와 데모를 작업 중심의 레시피로 묶었습니다. 정확한 시그니처가 필요하면 API 레퍼런스를, 애플리케이션이나 빌드 스크립트, CI 작업에 바로 쓸 수 있는 방법이 필요하면 이 페이지를 참고하세요
Choose an output format
var
PDF: THotPDF;
begin
PDF := THotPDF.Create(nil);
try
PDF.SavePreflightReport('Input.pdf', 'Input.preflight.txt');
PDF.SavePreflightReport('Input.pdf', 'Input.preflight.json', '', pfJSON);
PDF.SavePreflightReport('Input.pdf', 'Input.preflight.html', '', pfHTML);
PDF.SavePreflightReport('Input.pdf', 'Input.preflight.csv', '', pfCSV);
finally
PDF.Free;
end;
end;
텍스트 출력은 바이트 단위로 안정적이어서 diff에 적합합니다. JSON은 파이프라인 수집에 알맞으며, 모든 check, hint, warning에 안정적인 네임스페이스형 ruleId와, 가능한 경우 논리적 범위, 경로, PDF 키, 정확한 객체·페이지·바이트 좌표를 담은 구조화된 location을 제공합니다. HTML은 같은 식별자와 위치를 보여 주고, CSV는 스프레드시트와 배치 보고서 워크플로우를 위해 고정된 컬럼을 그대로 유지합니다
Validate PDF/VT documents
var
PDF: THotPDF;
Report: AnsiString;
begin
PDF := THotPDF.Create(nil);
try
if not PDF.ValidatePDFVT('Input.pdf', Report) then
WriteLn(string(Report));
finally
PDF.Free;
end;
end;
PDF/VT 보고서는 ISO 16612-2의 식별 정보와 문서 파트 구조를 중심으로 검사합니다. 검사 대상은 XMP GTS_PDFVTVersion(요소 텍스트 또는 RDF 속성 형태), 수정 날짜 일치 여부, PDF/X 기본 마커, output intent, DPartRoot, DPartRootNode, NodeNameList, 그리고 페이지 수준의 DPart 커버리지입니다
Apply a profile
var
PDF: THotPDF;
Report: AnsiString;
begin
PDF := THotPDF.Create(nil);
try
Report := PDF.CreatePreflightReportWithProfile(
'Input.pdf', '', 'project-preflight.ini', pfJSON);
finally
PDF.Free;
end;
end;
프로파일은 이름이 지정된 check와 warning, 또는 모든 hint를 억제합니다. 더 이상 쓰이지 않는 이름을 조용히 무시하는 것보다 안전하게 실패시키는 것이 중요하다면, 사용자가 작성한 프로파일을 적용하기 전에 ValidatePreflightProfile을 호출하세요
프리셋에서 재사용 가능한 프로파일 만들기
var
PDF: THotPDF;
Profile: THPDFPreflightProfile;
begin
PDF := THotPDF.Create(nil);
try
Profile := PDF.GetBuiltInPreflightProfile('compact');
Profile.DisableWarnings := 'OpenAction,JavaScript,URIAction';
PDF.SavePreflightProfile(Profile, 'compact-no-actions.ini');
finally
PDF.Free;
end;
end;
MergePreflightProfiles로 프리셋과 프로젝트별 이름을 합칠 수 있습니다. 공유 설정 파일을 갱신하기 전에는 DiffPreflightProfiles로 프로파일 변경 사항을 검토하세요
보고서를 PDF와 함께 보관하기
PDF.EmbedPreflightReportInPDF('Input.pdf', 'Input-with-report.pdf');
PDF.EmbedPreflightReportAsXMP('Input.pdf', 'Input-with-xmp-report.pdf');
텍스트 임베딩 경로는 마지막 EOF 마커 뒤에 읽을 수 있는 주석 블록을 덧붙입니다. XMP 경로는 메타데이터 패킷을 스캔하는 아카이브 워크플로우를 위해 RDF 형태의 페이로드를 덧붙입니다
Validate an embedded report
var
OriginalReport: AnsiString;
CurrentReport: AnsiString;
begin
if not PDF.LoadAndValidatePreflightReport(
'Input-with-report.pdf', OriginalReport, CurrentReport) then
WriteLn(string(PDF.ComparePreflightReports(OriginalReport, CurrentReport)));
end;
검증 경로는 임베드된 fingerprint를 원본 바이트에 대해 새로 실행한 preflight 결과와 비교합니다. diff 헬퍼는 줄 단위로 동작하며 HotPDF preflight 보고서에 맞게 조정되어 있습니다
Run a conservative repair pass
var
RepairsApplied: AnsiString;
begin
if PDF.RepairPDFFromPreflightReport(
'Broken.pdf', 'Broken-repaired.pdf', RepairsApplied) then
WriteLn(string(RepairsApplied));
end;
repair 헬퍼는 의도적으로 좁은 범위만 다룹니다. 마지막 EOF 마커 뒤의 후행 바이트와 누락된 EOF 마커는 처리하지만, cross-reference 테이블을 재구성하거나 스트림을 다시 쓰지는 않습니다
Aggregate many reports
Reports[0] := PDF.CreatePreflightReport('A.pdf');
Reports[1] := PDF.CreatePreflightReport('B.pdf');
Summary := PDF.AggregatePreflightReports(Reports);
집계 출력에는 PDF마다 상태 한 줄과 처리한 보고서, 실패, warning의 합계가 나옵니다. 입력 파일별 상세 보고서를 따로 보관하더라도 파이프라인에서 요약이 하나 필요할 때 유용합니다
Use the command-line tool
HotPDFPreflight Input.pdf -f json -o reports
HotPDFPreflight Input.pdf --pdfvt -o reports
HotPDFPreflight C:\Archive -r --preset compact -f text -o reports --aggregate reports\Aggregate.txt
HotPDFPreflight C:\Archive -r --profile project-preflight.ini -f html -o reports
CLI는 라이브러리 워크플로우를 그대로 따릅니다. 파일 하나 또는 디렉터리 재귀 입력, text / JSON / HTML 출력, 선택적 비밀번호, 선택적 프로파일, 내장 프리셋, verbose 진행 표시, 집계 요약을 지원합니다
Build a static dashboard
PreflightDashboard C:\Archive C:\Archive\preflight-dashboard
대시보드 데모는 index.html과 파일별 HTML 보고서를 생성합니다. 웹 서버가 필요 없으므로 출력물을 정적 아티팩트로 그대로 게시할 수 있습니다
Adapt to veraPDF-style JSON consumers
Report := PDF.CreatePreflightReport('Input.pdf');
JSON := PDF.ConvertPreflightReportToVeraPDFStyle(Report);
어댑터는 HotPDF의 의미 체계를 유지하면서, 이미 veraPDF 계열 JSON을 소비하는 도구에서 익숙하게 쓰는 검증 결과 구조로 실패 정보를 재구성합니다. 위반 항목은 네이티브 JSON 보고서와 동일한 안정적인 ruleId 및 구조화된 location 값을 유지합니다
Related Topics
|