Skip to content

Commit b8acbc3

Browse files
Merge pull request #749 from metanorma/pdf_ua1
verapdfcheck.yml updated for PDF/UA-1, metanorma/mn2pdf#287
2 parents dcd7e74 + d17013d commit b8acbc3

5 files changed

+115
-30
lines changed

.github/workflows/verapdfcheck.yml

+27-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: verapdfcheck
22

3-
on: push
3+
on: pull_request
44

55
jobs:
66
check:
@@ -33,21 +33,40 @@ jobs:
3333
run: |
3434
timeout 20s sh -c 'until curl http://localhost:8080/api/ | grep -q verapdf-rest; do echo "Waiting until container to be healthy..."; sleep 1; done'
3535
36-
- name: Check PDFs using veraPDF
36+
- name: Check PDFs for PDF/A-3a using veraPDF
3737
run: |
38-
find ./ -type f -name "*.pdf" -exec curl -F "file=@{}" localhost:8080/api/validate/3a -H "Accept:application/xml" -o "{}.verapdf.report.xml" \;
38+
find ./ -type f -name "*.pdf" -exec curl -F "file=@{}" localhost:8080/api/validate/3a -H "Accept:application/xml" -o "{}.verapdf.3a.report.xml" \;
3939
4040
- name: List files
4141
run: |
42-
find ./ -type f -name "*.verapdf.report.xml"
42+
find ./ -type f -name "*.verapdf.3a.report.xml"
4343
44-
- name: Check veraPDF XML reports on errors
44+
- name: Check veraPDF PDF/A-3a XML reports on errors
4545
run: |
46-
err_files_name=err.files.txt
46+
err_files_name=err.files.3a.txt
4747
[ -e $err_files_name ] && rm $err_files_name
48-
for f in $(find ./ -type f -name '*.verapdf.report.xml'); do grep -l 'status=\"failed\"' $f >> $err_files_name && cat $f; done
48+
for f in $(find ./ -type f -name '*.verapdf.3a.report.xml'); do grep -l 'status=\"failed\"' $f >> $err_files_name && cat $f; done
4949
if [ -s $err_files_name ]; then
50-
echo "veraPDF found PDF errors:"
50+
echo "veraPDF found PDF/A-3a errors:"
51+
cat $err_files_name
52+
exit 1
53+
fi
54+
55+
- name: Check PDFs for PDF/UA-1 using veraPDF
56+
run: |
57+
find ./ -type f -name "*.pdf" -exec curl -F "file=@{}" localhost:8080/api/validate/ua1 -H "Accept:application/xml" -o "{}.verapdf.ua1.report.xml" \;
58+
59+
- name: List files
60+
run: |
61+
find ./ -type f -name "*.verapdf.ua1.report.xml"
62+
63+
- name: Check veraPDF PDF/UA-1 XML reports on errors
64+
run: |
65+
err_files_name=err.files.ua1.txt
66+
[ -e $err_files_name ] && rm $err_files_name
67+
for f in $(find ./ -type f -name '*.verapdf.ua1.report.xml'); do grep -l 'status=\"failed\"' $f >> $err_files_name && cat $f; done
68+
if [ -s $err_files_name ]; then
69+
echo "veraPDF found PDF/UA-1 errors:"
5170
cat $err_files_name
5271
exit 1
5372
fi

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ XSLT_GENERATED := xslt/iec.international-standard.xsl \
8181
xslt/bipm.rapport.xsl \
8282
xslt/jcgm.standard.xsl
8383

84-
MN2PDF_DOWNLOAD_PATH := https://github.com/metanorma/mn2pdf/releases/download/v2.01/mn2pdf-2.01.jar
84+
MN2PDF_DOWNLOAD_PATH := https://github.com/metanorma/mn2pdf/releases/download/v2.02/mn2pdf-2.02.jar
8585
# MN2PDF_DOWNLOAD_PATH := https://maven.pkg.github.com/metanorma/mn2pdf/com/metanorma/fop/mn2pdf/1.7/mn2pdf-1.7.jar
8686
MN2PDF_EXECUTABLE := $(notdir $(MN2PDF_DOWNLOAD_PATH))
8787

xslt_src/common.xsl

+58-1
Original file line numberDiff line numberDiff line change
@@ -8825,6 +8825,7 @@
88258825

88268826
<fo:block role="SKIP">
88278827
<xsl:apply-templates />
8828+
<xsl:if test="$isGenerateTableIF = 'false' and count(node()) = 0">&#xa0;</xsl:if>
88288829
</fo:block>
88298830
</fo:table-cell>
88308831
</xsl:template> <!-- cell in table header row - 'th' -->
@@ -8901,6 +8902,8 @@
89018902

89028903
<xsl:if test="$isGenerateTableIF = 'true'">&#xa0;<fo:inline id="{@id}_end">end</fo:inline></xsl:if> <!-- to determine width of text --> <!-- <xsl:value-of select="$hair_space"/> -->
89038904

8905+
<xsl:if test="$isGenerateTableIF = 'false' and count(node()) = 0">&#xa0;</xsl:if>
8906+
89048907
</fo:block>
89058908
</fo:table-cell>
89068909
</xsl:template> <!-- td -->
@@ -12428,6 +12431,9 @@
1242812431
<xsl:call-template name="insert_basic_link">
1242912432
<xsl:with-param name="element">
1243012433
<fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
12434+
<xsl:if test="$isLinkToEmbeddedFile = 'true'">
12435+
<xsl:attribute name="role">Annot</xsl:attribute>
12436+
</xsl:if>
1243112437
<xsl:choose>
1243212438
<xsl:when test="normalize-space(.) = ''">
1243312439
<xsl:call-template name="add-zero-spaces-link-java">
@@ -19869,6 +19875,12 @@
1986919875
<!-- Get or calculate depth of the element -->
1987019876
<xsl:template name="getLevel">
1987119877
<xsl:param name="depth"/>
19878+
<!-- <xsl:message>
19879+
<xsl:choose>
19880+
<xsl:when test="local-name() = 'title'">title=<xsl:value-of select="."/></xsl:when>
19881+
<xsl:when test="local-name() = 'clause'">clause/title=<xsl:value-of select="*[local-name() = 'title']"/></xsl:when>
19882+
</xsl:choose>
19883+
</xsl:message> -->
1987219884
<xsl:choose>
1987319885
<xsl:when test="normalize-space(@depth) != ''">
1987419886
<xsl:value-of select="@depth"/>
@@ -19889,15 +19901,45 @@
1988919901
<xsl:when test="ancestor::*[local-name() = 'preface']">
1989019902
<xsl:value-of select="$level_total - 2"/>
1989119903
</xsl:when>
19904+
<xsl:when test="ancestor::*[local-name() = 'sections'] and self::*[local-name() = 'title']">
19905+
<xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][2]/*[local-name() = 'title']/@depth)"/>
19906+
<xsl:choose>
19907+
<xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
19908+
<xsl:value-of select="number($upper_clause_depth + 1)"/>
19909+
</xsl:when>
19910+
<xsl:otherwise>
19911+
<xsl:value-of select="$level_total - 2"/>
19912+
</xsl:otherwise>
19913+
</xsl:choose>
19914+
</xsl:when>
1989219915
<xsl:when test="ancestor::*[local-name() = 'sections']">
19893-
<xsl:value-of select="$level_total - 1"/>
19916+
<xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][1]/*[local-name() = 'title']/@depth)"/>
19917+
<xsl:choose>
19918+
<xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
19919+
<xsl:value-of select="number($upper_clause_depth + 1)"/>
19920+
</xsl:when>
19921+
<xsl:otherwise>
19922+
<xsl:value-of select="$level_total - 1"/>
19923+
</xsl:otherwise>
19924+
</xsl:choose>
1989419925
</xsl:when>
1989519926
<xsl:when test="ancestor::*[local-name() = 'bibliography']">
1989619927
<xsl:value-of select="$level_total - 1"/>
1989719928
</xsl:when>
1989819929
<xsl:when test="parent::*[local-name() = 'annex']">
1989919930
<xsl:value-of select="$level_total - 1"/>
1990019931
</xsl:when>
19932+
<xsl:when test="ancestor::*[local-name() = 'annex'] and self::*[local-name() = 'title']">
19933+
<xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][2]/*[local-name() = 'title']/@depth)"/>
19934+
<xsl:choose>
19935+
<xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
19936+
<xsl:value-of select="number($upper_clause_depth + 1)"/>
19937+
</xsl:when>
19938+
<xsl:otherwise>
19939+
<xsl:value-of select="$level_total - 1"/>
19940+
</xsl:otherwise>
19941+
</xsl:choose>
19942+
</xsl:when>
1990119943
<xsl:when test="ancestor::*[local-name() = 'annex']">
1990219944
<xsl:value-of select="$level_total"/>
1990319945
</xsl:when>
@@ -20609,4 +20651,19 @@
2060920651
</xsl:if>
2061020652
</xsl:template>
2061120653

20654+
<xsl:template match="@*|node()" mode="set_table_role_skip">
20655+
<xsl:copy>
20656+
<xsl:apply-templates select="@*|node()" mode="set_table_role_skip"/>
20657+
</xsl:copy>
20658+
</xsl:template>
20659+
20660+
<xsl:template match="*[starts-with(local-name(), 'table')]" mode="set_table_role_skip">
20661+
<xsl:copy>
20662+
<xsl:apply-templates select="@*" mode="set_table_role_skip"/>
20663+
<xsl:attribute name="role">SKIP</xsl:attribute>
20664+
<xsl:apply-templates select="node()" mode="set_table_role_skip"/>
20665+
</xsl:copy>
20666+
</xsl:template>
20667+
20668+
2061220669
</xsl:stylesheet>

xslt_src/iec.international-standard.core.xsl

+6-4
Original file line numberDiff line numberDiff line change
@@ -1355,9 +1355,11 @@
13551355
</xsl:template>
13561356

13571357
<xsl:template match="iec:preface//iec:clause[@type = 'toc']" priority="3">
1358-
<fo:block-container>
1358+
<fo:block-container role="SKIP">
1359+
<!-- render 'Contents' outside if role="TOC" -->
1360+
<xsl:apply-templates select="*[local-name() = 'title']"/>
13591361
<fo:block role="TOC">
1360-
<xsl:apply-templates />
1362+
<xsl:apply-templates select="node()[not(local-name() = 'title')]"/>
13611363

13621364
<xsl:if test="count(*) = 1 and *[local-name() = 'title']"> <!-- if there isn't user ToC -->
13631365
<xsl:variable name="docid">
@@ -1372,7 +1374,7 @@
13721374
</xsl:template>
13731375

13741376
<xsl:template match="iec:preface//iec:clause[@type = 'toc']/iec:title" priority="3">
1375-
<fo:block font-size="12pt" text-align="center" margin-bottom="22pt" role="H1">
1377+
<fo:block font-size="12pt" text-align="center" margin-bottom="22pt">
13761378
<xsl:call-template name="addLetterSpacing">
13771379
<xsl:with-param name="text" select="java:toUpperCase(java:java.lang.String.new(.))"/>
13781380
</xsl:call-template>
@@ -1842,7 +1844,7 @@
18421844
<xsl:variable name="level">
18431845
<xsl:call-template name="getLevel"/>
18441846
</xsl:variable>
1845-
1847+
18461848
<xsl:variable name="font-size">
18471849
<xsl:choose>
18481850
<xsl:when test="ancestor::iec:sections and $level = 1">11pt</xsl:when>

xslt_src/iso.international-standard.core.xsl

+23-16
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,7 @@
14781478

14791479
<xsl:template name="insertCoverPage">
14801480
<xsl:if test="$isGenerateTableIF = 'false'"> <!-- no need cover page for auto-layout algorithm -->
1481+
<xsl:variable name="fo_cover_page">
14811482
<!-- cover page -->
14821483
<xsl:choose>
14831484
<xsl:when test="$layoutVersion = '1951'">
@@ -1792,7 +1793,7 @@
17921793
<!-- International
17931794
Standard -->
17941795
<fo:table-cell number-columns-spanned="2" padding-left="6mm">
1795-
<fo:block-container height="46mm">
1796+
<fo:block-container height="46mm" role="SKIP">
17961797
<fo:block font-size="20pt" font-weight="bold" line-height="1.25" margin-top="3mm">
17971798

17981799
<xsl:variable name="updates-document-type" select="/iso:iso-standard/iso:bibdata/iso:ext/iso:updates-document-type"/>
@@ -1863,8 +1864,7 @@
18631864

18641865
<fo:table-row height="46mm">
18651866
<fo:table-cell number-columns-spanned="2" border-right="{$cover_page_border}">
1866-
<fo:block>&#xa0;
1867-
</fo:block>
1867+
<fo:block role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block>
18681868
</fo:table-cell>
18691869
<fo:table-cell number-columns-spanned="2" display-align="after" padding-left="6mm">
18701870
<fo:block font-size="19pt" font-weight="bold" line-height="1">
@@ -1877,12 +1877,12 @@
18771877
</fo:table-row>
18781878

18791879
<fo:table-row height="1.4mm" font-size="0pt">
1880-
<fo:table-cell border-bottom="{$cover_page_border}"><fo:block>&#xa0;</fo:block></fo:table-cell>
1881-
<fo:table-cell number-columns-spanned="2"><fo:block>&#xa0;</fo:block></fo:table-cell>
1882-
<fo:table-cell border-bottom="{$cover_page_border}"><fo:block>&#xa0;</fo:block></fo:table-cell>
1880+
<fo:table-cell border-bottom="{$cover_page_border}"><fo:block role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block></fo:table-cell>
1881+
<fo:table-cell number-columns-spanned="2"><fo:block role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block></fo:table-cell>
1882+
<fo:table-cell border-bottom="{$cover_page_border}"><fo:block role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block></fo:table-cell>
18831883
</fo:table-row>
18841884
<fo:table-row height="1.4mm" font-size="0pt">
1885-
<fo:table-cell number-columns-spanned="4"><fo:block>&#xa0;</fo:block></fo:table-cell>
1885+
<fo:table-cell number-columns-spanned="4"><fo:block role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block></fo:table-cell>
18861886
</fo:table-row>
18871887

18881888
<fo:table-row>
@@ -1918,7 +1918,7 @@
19181918
</fo:block-container>
19191919
</fo:table-cell>
19201920
<fo:table-cell number-columns-spanned="2" padding-left="6mm">
1921-
<fo:block margin-top="2.5mm" line-height="1.1">
1921+
<fo:block margin-top="2.5mm" line-height="1.1" role="SKIP">
19221922

19231923
<xsl:if test="not($stage-abbreviation = 'DIS' or $stage-abbreviation = 'DAMD' or $stage-abbreviation = 'DAM')">
19241924
<xsl:variable name="edition_and_date">
@@ -2574,7 +2574,7 @@
25742574
</fo:block>
25752575
</fo:block-container>
25762576
</fo:flow>
2577-
</xsl:otherwise>
2577+
</xsl:otherwise>
25782578
</xsl:choose>
25792579

25802580

@@ -2776,7 +2776,11 @@
27762776
</fo:page-sequence>
27772777
</xsl:otherwise>
27782778
</xsl:choose>
2779-
</xsl:if> <!-- $isGenerateTableIF = ' false' -->
2779+
</xsl:variable>
2780+
2781+
<xsl:apply-templates select="xalan:nodeset($fo_cover_page)" mode="set_table_role_skip"/>
2782+
2783+
</xsl:if> <!-- $isGenerateTableIF = 'false' -->
27802784
</xsl:template> <!-- END insertCoverPage -->
27812785

27822786

@@ -4947,6 +4951,7 @@
49474951
<xsl:template name="insertLastPage_2024">
49484952
<fo:page-sequence master-reference="last-page_2024" force-page-count="no-force">
49494953
<fo:flow flow-name="xsl-region-body">
4954+
<xsl:variable name="fo_last_page">
49504955
<fo:table table-layout="fixed" width="100%" margin-bottom="-1mm">
49514956
<xsl:call-template name="insertInterFont"/>
49524957
<fo:table-column column-width="proportional-column-width(73)"/>
@@ -4960,15 +4965,15 @@
49604965
<xsl:call-template name="insertLogoImages2024"/>
49614966
</fo:block>
49624967
</fo:table-cell>
4963-
<fo:table-cell number-columns-spanned="2"><fo:block>&#xa0;</fo:block></fo:table-cell>
4968+
<fo:table-cell number-columns-spanned="2"><fo:block role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block></fo:table-cell>
49644969
</fo:table-row>
49654970
<fo:table-row height="1.4mm" font-size="0pt">
4966-
<fo:table-cell border-bottom="{$cover_page_border}"><fo:block>&#xa0;</fo:block></fo:table-cell>
4967-
<fo:table-cell number-columns-spanned="2"><fo:block>&#xa0;</fo:block></fo:table-cell>
4968-
<fo:table-cell border-bottom="{$cover_page_border}"><fo:block>&#xa0;</fo:block></fo:table-cell>
4971+
<fo:table-cell border-bottom="{$cover_page_border}"><fo:block role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block></fo:table-cell>
4972+
<fo:table-cell number-columns-spanned="2"><fo:block role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block></fo:table-cell>
4973+
<fo:table-cell border-bottom="{$cover_page_border}"><fo:block role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block></fo:table-cell>
49694974
</fo:table-row>
49704975
<fo:table-row height="2mm" font-size="0pt">
4971-
<fo:table-cell number-columns-spanned="4"><fo:block>&#xa0;</fo:block></fo:table-cell>
4976+
<fo:table-cell number-columns-spanned="4"><fo:block role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block></fo:table-cell>
49724977
</fo:table-row>
49734978
<fo:table-row height="182mm"> <!-- 174 -->
49744979
<fo:table-cell number-columns-spanned="2" display-align="after" border-right="{$cover_page_border}">
@@ -5004,6 +5009,8 @@
50045009
</fo:table-row>
50055010
</fo:table-body>
50065011
</fo:table>
5012+
</xsl:variable>
5013+
<xsl:apply-templates select="xalan:nodeset($fo_last_page)" mode="set_table_role_skip"/>
50075014
</fo:flow>
50085015
</fo:page-sequence>
50095016
</xsl:template> <!-- END: insertLastPage_2024 -->
@@ -5325,7 +5332,7 @@
53255332
</xsl:template>
53265333

53275334
<xsl:template name="insertLastBlock">
5328-
<fo:block id="lastBlock" font-size="1pt" keep-with-previous="always" role="SKIP">&#xA0;</fo:block>
5335+
<fo:block id="lastBlock" font-size="1pt" keep-with-previous="always" role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block>
53295336
</xsl:template>
53305337

53315338
</xsl:stylesheet>

0 commit comments

Comments
 (0)