Skip to content

Commit

Permalink
move verify functions and use in hyperref
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrike Fischer committed Feb 17, 2021
1 parent 5dc67da commit 724ba82
Show file tree
Hide file tree
Showing 3 changed files with 318 additions and 105 deletions.
10 changes: 5 additions & 5 deletions experiments/verify.tex
Expand Up @@ -101,7 +101,7 @@
\ExplSyntaxOff

\begin{document}
\section{Verifying standard requirements}
\subsection{Verifying standard requirements}

Standards like pdf/A set requirements on a PDF: Some things have be in the PDF, e.g. the catalog has to contain a /Lang entry and an colorprofile and an /OutputIntent, some other things are forbidden or restricted, e.g. the action dictionary of an annotation should not contain Javascript.

Expand Down Expand Up @@ -164,7 +164,7 @@ \section{Verifying standard requirements}
The following describe the requirements which can be currently tested. Requirements with a value should use \cs{pdfmeta_standard_verify:nn} or \cs{pdfmeta_standard_verify:nnN} to test a local value against the standard.
The rule numbers refer to \url{https://docs.verapdf.org/validation/pdfa-part1/}

\subsection{Simple tests without handler}
\subsubsection{Simple tests without handler}


\begin{description}
Expand All @@ -184,7 +184,7 @@ \subsection{Simple tests without handler}
\item[|form_no_AA|] (6.9-3) no /AA dictionary in form field
\end{description}

\subsection{Tests with values and special handlers}
\subsubsection{Tests with values and special handlers}

\begin{description}

Expand All @@ -195,10 +195,10 @@ \subsection{Tests with values and special handlers}
\item[|outputintent_subtype|] this requirement stores allowed names for the /Outputintent subtype like |GTS_PDFA1|.
This value is typically only read.
\item[|named_actions|] this requirement restricts the list of allowed named actions to |NextPage|, |PrevPage|, |FirstPage|, |LastPage|.
The check should supply the named action without slash (e.g. |View|).
The check should supply the named action without slash (e.g. |View| (failure) or |NextPage| (pass)).

\item[|annot_action_A|] (rule 6.6.1-1) this requirement restricts the allowed subtypes of the
/A dictionary of an action. The check should supply the user subtype without slash e.g. as |GoTo| or |Movie|.
/A dictionary of an action. The check should supply the user subtype without slash e.g. as |GoTo| (pass) or |Movie| (failure).
\end{description}


Expand Down
58 changes: 23 additions & 35 deletions hyperref-generic.dtx
Expand Up @@ -1940,15 +1940,7 @@
\bool_if:NTF \l_@@_annot_Named_bool
{
\group_begin:
\bool_set_true:N\l_tmpa_bool
\prop_get:NnNT \g_pdfmeta_standard_prop {named_actions} \l_@@_tmpa_tl
{
\tl_if_in:NnF \l_@@_tmpa_tl {#1}
{
\bool_set_false:N\l_tmpa_bool
}
}
\bool_if:NTF \l_tmpa_bool
\pdfmeta_standard_verify:nnTF {named_actions}{#1}
{
\mode_leave_vertical:
\pdfdict_put:nnx {l_hyp/annot/A/Named}{N}
Expand Down Expand Up @@ -3896,16 +3888,16 @@
{Helv} {\pdf_object_ref:n {l_@@_font_helvetica_obj} }
\pdfmanagement_add:nnx {Catalog /AcroForm}
{DA}{(/Helv~10~Tf~0~g)}
\prop_if_in:NnTF\g_pdfmeta_standard_prop {form_no_NeedAppearance}
{
\pdfmanagement_remove:nn {Catalog / AcroForm }{NeedAppearances}
}
\pdfmeta_standard_verify:nTF {form_no_NeedAppearance}
{
\legacy_if:nT { HyField@NeedAppearances }
{
\pdfmanagement_add:nnn {Catalog / AcroForm }{NeedAppearances}{true}
}
}
{
\pdfmanagement_remove:nn {Catalog / AcroForm }{NeedAppearances}
}
}
\MakeFieldObject
{
Expand Down Expand Up @@ -4166,15 +4158,7 @@
\DefaultOptionsofPushButton,#1
}
\PDFForm@Name
\prop_if_in:NnTF \g_pdfmeta_standard_prop {annot_action_no_A}
{
\msg_error:nn { hyp }{ pdfa-no-push-button }
\LayoutPushButtonField
{
\mode_leave_vertical:
\MakeButtonField{#2}
}
}
\pdfmeta_standard_verify:nnTF {annot_action_A}{JavaScript}
{
\HyField@FlagsPushButton
\legacy_if:nT {Fld@hidden}
Expand All @@ -4195,7 +4179,15 @@
{\box_use:N\l_tmpa_box}
\HyField@AddToFields
}
}
}
{
\msg_error:nn { hyp }{ pdfa-no-push-button }
\LayoutPushButtonField
{
\mode_leave_vertical:
\MakeButtonField{#2}
}
}
\group_end:
}

Expand Down Expand Up @@ -4245,11 +4237,7 @@
\DefaultOptionsofReset,#1
}
\mode_leave_vertical:
\prop_if_in:NnTF \g_pdfmeta_standard_prop {annot_action_no_A}
{
\msg_error:nn { hyp }{ pdfa-no-reset-button }
\MakeButtonField{#2}
}
\pdfmeta_standard_verify:nnTF {annot_action_A}{ResetForm}
{
\HyField@FlagsPushButton
\legacy_if:nT { Fld@hidden }
Expand All @@ -4265,6 +4253,10 @@
\HyField@AddToFields
\box_use:N \l_tmpa_box
}
{
\msg_error:nn { hyp }{ pdfa-no-reset-button }
\MakeButtonField{#2}
}
\group_end:
}

Expand Down Expand Up @@ -4479,7 +4471,7 @@
{%
\exp_args:Ne\str_if_eq:nnF {\Fld@X@additionalactions}{}
{
\prop_if_in:NnF \g_pdfmeta_standard_prop {annot_widget_no_AA}
\pdfmeta_standard_verify:nT {annot_widget_no_AA}
{/AA<<\Fld@X@additionalactions>>}
}
}
Expand Down Expand Up @@ -4549,8 +4541,6 @@
}
\ExplSyntaxOff
\ExplSyntaxOn
\prop_if_in:NnF \g_pdfmeta_standard_prop {annot_action_no_A}
{
\def\PDFForm@Push
{
/Subtype/Widget
Expand Down Expand Up @@ -4583,7 +4573,7 @@
/A<</S/JavaScript/JS(\Hy@escapestring{\Fld@onclick@code})>>
\Fld@additionalactions
}
}

\ExplSyntaxOff
\def\PDFForm@List{%
/Subtype/Widget%
Expand Down Expand Up @@ -4744,8 +4734,6 @@
\Fld@additionalactions
}
\ExplSyntaxOn
\prop_if_in:NnF \g_pdfmeta_standard_prop {annot_action_no_A}
{
\def\PDFForm@Reset{%
/Subtype/Widget%
\Fld@annotflags
Expand Down Expand Up @@ -4774,7 +4762,7 @@
/A<</S/ResetForm>>%
\Fld@additionalactions
}%
}


%these patterns are used in hyperref checks.
%it is unclear if they are really useful and if a backend support is
Expand Down

0 comments on commit 724ba82

Please sign in to comment.