summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tagpdf/ex-alt-actualtext.tex
blob: 148a010701c58b3f1290a9479f751aa10aeba8d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
% !Mode:: "TeX:DE:UTF-8:Main"

\RequirePackage{pdfmanagement-testphase}
\DeclareDocumentMetadata{pdfversion=1.7,lang=de-DE}

\documentclass{article}

\usepackage{tagpdf}
\tagpdfsetup{tabsorder=structure,
             activate}
\usepackage{iftex}             
\iftutex
  \usepackage{fontspec}
  \usepackage{unicode-math}
  \usepackage{luacode}
  \newfontface\zerowidthfont{freeserif}
\else
  \usepackage[T1]{fontenc}
\fi


\usepackage{graphicx}
% This is not a perfectly tagged document!
% It doesn't use paratagging!
% one sentence is not marked (luatex will mark it as artifact)
% with pdflatex there is a encoding problem with the math

\begin{document}
\pagestyle{empty}


%This isn't read by voice software
Etwas unmarkierter Text.

%This read ok by voice software
\tagstructbegin{tag=P}
  \tagmcbegin{tag=P}
   Ein Satz ohne Umlaute.
  \tagmcend
\tagstructend

%This read ok by  nvda, but adobe has difficulties with the umlauts
\tagstructbegin{tag=P}
  \tagmcbegin{tag=P}
   Grüße an die Welt und die öde Wüste.
  \tagmcend
\tagstructend

\newpage
% alttext is read,
% actualtext copy & pasted
\tagstructbegin{tag=P,alttext=Dies ist ein Text,actualtext=Copy}
  \tagmcbegin{tag=P}
   Test
  \tagmcend
\tagstructend

%alttext is read,
%actualtext copy & pasted
\tagstructbegin{tag=P}
 \tagmcbegin{tag=P,alttext=Dies ist ein zweiter Text,actualtext=Copy}
  Test
 \tagmcend
\tagstructend


%nvda: alttext of structure is read
%adobe: alttext of inner mc is read
% result of copy & paste of this page in adobe reader:
% why twice??????
% Copy Copy
% Copy Copy
% Copystruct Copystruct

\tagstructbegin{tag=P,alttext=Dies ist der Structuretext,actualtext=Copystruct}
 \tagmcbegin{tag=P,alttext=Dies ist der innere  Text,actualtext=Copymc}
  Test
 \tagmcend
\tagstructend



\newpage
% test of "Formula" tag:
% content is more or less ignored. This is not against the documentation:
% Formula is explicitly describes as an "illustration", something with a content
% which can not be read directly.
% But it is a problem that nvda ignores it even with an alt text.

%test of Formula tag + alttext in the mc
%pdflatex
%nvda: content is ignored
%adobe: reads the alt text but without {} and ()

%luatex (unicode-math):
% nvda: doesn't read
%adobe: doesn't read  (warning "empty page")

\tagstructbegin{tag=Formula}
 \tagmcbegin {tag=Formula,alttext={\frac{a}{b}+c + \int_1^n f(x)}}
  xxx $\frac{a}{b}+c + \int_1^n f(x)$
 \tagmcend
\tagstructend

\newpage

%test of Formula tag + alttext in the struct
\tagstructbegin{tag=Formula,alttext=Dies ist eine Formel}
 \tagmcbegin {tag=Formula}
  formula
 \tagmcend
\tagstructend

\newpage
% test of Formula tag without alttext
% pdflatex
% adobe: reads it more or less (without commands naturally)
% nvda: ignores it

%lualatex
%nvda: ignores it
%adobe: ignores it

\tagstructbegin{tag=Formula}
 \tagmcbegin {tag=Formula}
 formula: $\frac{a}{b}+c + \int_1^n f(x)$
 \tagmcend
\tagstructend

\newpage
% luatex:
% nvda: reads the alttext ok, {} and () are only read if the symbol level is (at leat) "most"
% adobe: something is read but it is not understable

\tagstructbegin{tag=P}
 \tagmcbegin {tag=P,alttext={\frac{x}{y}+c + \int_1^n f(x)}}
  $\frac{x}{y}+c + \int_1^n f(x)$
 \tagmcend
\tagstructend

%pdftex
% sum is read as "pi"
%luatex
%adobe: almost nothing read (only 1 and =)
%nvda: similar, obviously both have problems with the unicode math symbols
\tagstructbegin{tag=P}
 \tagmcbegin {tag=P}
  $\sum_1^n (1) = n $
 \tagmcend
\tagstructend

\newpage

\tagmcbegin{tag=P,
 actualtext=Ente,
 alttext=Dies ist eine Ente}
 %% a char is needed so that actualtext works,
 \tagpdfifluatexTF
  {{\zerowidthfont^^^^200c}}%
  {\makebox[0pt][l]{.}}%
 %it seems not to be needed for alttext and voice software ....
 \includegraphics[width=1cm]{example-image-duck}
\tagmcend

\tagmcbegin{tag=P,
 actualtext=Ente,
 alttext=Dies ist eine zweite Ente}
 %% a char is needed so that actualtext works,
 %\tagpdfifluatexTF
 %  {{\zerowidthfont^^^^200c}}%
 %  {\makebox[0pt][l]{.}}%
 %it seems not to be needed for alttext and voice software ....
 \includegraphics[width=1cm]{example-image-duck}
\tagmcend


\end{document}