Skip to content

접근 가능한 PDF

태그 구조, 대체 텍스트, 언어 태깅을 사용하여 스크린 리더 및 보조 기술과 호환되는 접근 가능한 PDF를 생성합니다.

PDF를 접근 가능하게 만드는 것은?

요구사항중요한 이유
구조 태그스크린 리더가 탐색을 위해 제목/단락/목록 태그를 사용
대체 텍스트이미지를 볼 수 없는 사용자에게 이미지를 설명
언어 태그리더에게 텍스트 발음 방법을 알려줌
읽기 순서시각적 레이아웃과 독립적인 논리적 순서
테이블 헤더데이터 셀을 열/행 컨텍스트와 연결
북마크긴 문서를 위한 키보드 탐색

표준

표준범위
PDF/UA-2 (ISO 14289-2)PDF 범용 접근성
WCAG 2.1웹 콘텐츠 접근성 가이드라인
Section 508미국 연방 접근성
EN 301 549EU 접근성 요구사항

전체 코드 예제

php
<?php

declare(strict_types=1);

require __DIR__ . '/vendor/autoload.php';

use TcpdfNext\Document;
use TcpdfNext\Enums\Alignment;
use TcpdfNext\Accessibility\TagManager;

// ── 1. 태그 PDF 활성화 ───────────────────────────────────────────────
$pdf = Document::create()
    ->setTitle('Accessibility Report 2026')
    ->setAuthor('Acme Corp')
    ->setLanguage('en-US')
    ->setTagged(true)
    ->setDisplayDocTitle(true)
    ->addPage();

$tag = $pdf->getTagManager();

// ── 2. 제목 (H1) ───────────────────────────────────────────────────
$tag->beginTag('H1');
$pdf->setFont('helvetica', style: 'B', size: 24)
    ->cell(0, 14, 'Accessibility Report 2026', newLine: true);
$tag->endTag();

// ── 3. 단락 ──────────────────────────────────────────────────────
$tag->beginTag('P');
$pdf->setFont('times', size: 12)
    ->multiCell(0, 7, 'Acme Corp is committed to producing documents that '
        . 'meet PDF/UA and WCAG 2.1 AA standards, ensuring equal access '
        . 'for all users regardless of ability.');
$tag->endTag();

// ── 4. 부제목 (H2) ──────────────────────────────────────────────
$tag->beginTag('H2');
$pdf->setFont('helvetica', style: 'B', size: 18)
    ->cell(0, 12, 'Key Metrics', newLine: true);
$tag->endTag();

// ── 5. 태그가 지정된 목록 ────────────────────────────────────────────
$items = [
    'Documents audited: 1,240',
    'Compliance rate: 98.7%',
    'Issues resolved: 412',
];

$tag->beginTag('L');
foreach ($items as $item) {
    $tag->beginTag('LI');

    $tag->beginTag('Lbl');
    $pdf->setFont('helvetica', size: 11)
        ->cell(8, 7, "\u{2022}");
    $tag->endTag(); // Lbl

    $tag->beginTag('LBody');
    $pdf->cell(0, 7, $item, newLine: true);
    $tag->endTag(); // LBody

    $tag->endTag(); // LI
}
$tag->endTag(); // L

// ── 6. 대체 텍스트가 있는 이미지 ────────────────────────────────────
$tag->beginTag('Figure');
$pdf->image(
    file:    __DIR__ . '/assets/compliance-chart.png',
    x:       null,
    y:       null,
    width:   120,
    height:  null,
    altText: 'Bar chart showing compliance rate rising from 91% in 2023 '
           . 'to 98.7% in 2026 across four consecutive years.',
);
$tag->beginTag('Caption');
$pdf->setFont('helvetica', style: 'I', size: 9)
    ->cell(0, 6, 'Figure 1: Compliance trend 2023-2026', newLine: true);
$tag->endTag(); // Caption
$tag->endTag(); // Figure

// ── 7. 장식 요소를 아티팩트로 (스크린 리더가 건너뜀) ─────
$tag->beginArtifact('Layout');
$pdf->setDrawColor(200, 200, 200)
    ->line(15, $pdf->getY(), 195, $pdf->getY());
$tag->endArtifact();

// ── 8. 태그가 지정된 테이블 ───────────────────────────────────────
$tag->beginTag('H2');
$pdf->setFont('helvetica', style: 'B', size: 18)
    ->cell(0, 12, 'Quarterly Results', newLine: true);
$tag->endTag();

$tag->beginTag('Table');

// 헤더 행
$tag->beginTag('TR');
foreach (['Quarter', 'Audited', 'Passed', 'Rate'] as $header) {
    $tag->beginTag('TH', attributes: ['scope' => 'col']);
    $pdf->setFont('helvetica', style: 'B', size: 10)
        ->cell(45, 8, $header, border: 1);
    $tag->endTag();
}
$tag->endTag(); // TR

// 데이터 행
$rows = [
    ['Q1', '310', '305', '98.4%'],
    ['Q2', '320', '316', '98.8%'],
    ['Q3', '305', '302', '99.0%'],
    ['Q4', '305', '301', '98.7%'],
];
foreach ($rows as $row) {
    $tag->beginTag('TR');
    foreach ($row as $i => $cell) {
        $tagName = $i === 0 ? 'TH' : 'TD';
        $attrs   = $i === 0 ? ['scope' => 'row'] : [];
        $tag->beginTag($tagName, attributes: $attrs);
        $pdf->setFont('times', size: 10)
            ->cell(45, 8, $cell, border: 1);
        $tag->endTag();
    }
    $tag->endTag(); // TR
}
$tag->endTag(); // Table

// ── 9. 외국어 텍스트의 언어 태깅 ──────────────────────────────
$tag->beginTag('P', attributes: ['lang' => 'de-DE']);
$pdf->setFont('times', size: 11)
    ->multiCell(0, 7, 'Barrierefreiheit ist ein grundlegendes Recht.');
$tag->endTag();

// ── 10. 저장 ──────────────────────────────────────────────────
$pdf->save(__DIR__ . '/accessible-report.pdf');

echo 'Accessible PDF created.' . PHP_EOL;

HTML 자동 태깅

TCPDF-Next는 시맨틱 HTML에서 자동으로 구조 태그를 생성할 수 있습니다:

php
$pdf = Document::create()
    ->setTagged(true)
    ->setLanguage('en-US')
    ->addPage();

$pdf->setAutoTagging(true)
    ->writeHtml(<<<'HTML'
        <h1>Report</h1>
        <p>Summary paragraph.</p>
        <img src="chart.png" alt="Revenue chart showing 15% growth" />
        <table>
            <tr><th>Q</th><th>Revenue</th></tr>
            <tr><td>Q1</td><td>$548M</td></tr>
        </table>
    HTML);
HTML 요소PDF 태그
<h1>--<h6>H1--H6
<p>P
<img alt="...">Figure
<table>Table
<th>TH
<td>TD
<ul>, <ol>L
<li>LI
<a>Link

접근성 체크리스트

  • [ ] setTitle() -- 문서 제목 설정
  • [ ] setDisplayDocTitle(true) -- 뷰어가 파일명 대신 제목 표시
  • [ ] setLanguage('en-US') -- 문서 언어 선언
  • [ ] 모든 콘텐츠가 구조 태그로 감싸져 있음
  • [ ] 제목이 순차적 순서 (H1, H2, H3 -- 건너뛰기 없음)
  • [ ] 모든 의미 있는 이미지에 altText 포함
  • [ ] 장식 이미지는 아티팩트로 표시
  • [ ] 테이블에 scope 속성이 있는 TH 셀 포함
  • [ ] 읽기 순서가 논리적 순서와 일치
  • [ ] 색상 대비 비율 최소 4.5:1

검증

bash
# PDF/UA 검증에 PAC (PDF Accessibility Checker) 사용
# https://pdfua.foundation/en/pac-download/

더 읽을거리

LGPL-3.0-or-later 라이선스로 배포됩니다.