Skip to content

Commit

Permalink
Merge pull request #749 from metanorma/pdf_ua1
Browse files Browse the repository at this point in the history
verapdfcheck.yml updated for PDF/UA-1, metanorma/mn2pdf#287
  • Loading branch information
Intelligent2013 authored Sep 29, 2024
2 parents dcd7e74 + d17013d commit b8acbc3
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 30 deletions.
35 changes: 27 additions & 8 deletions .github/workflows/verapdfcheck.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: verapdfcheck

on: push
on: pull_request

jobs:
check:
Expand Down Expand Up @@ -33,21 +33,40 @@ jobs:
run: |
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'
- name: Check PDFs using veraPDF
- name: Check PDFs for PDF/A-3a using veraPDF
run: |
find ./ -type f -name "*.pdf" -exec curl -F "file=@{}" localhost:8080/api/validate/3a -H "Accept:application/xml" -o "{}.verapdf.report.xml" \;
find ./ -type f -name "*.pdf" -exec curl -F "file=@{}" localhost:8080/api/validate/3a -H "Accept:application/xml" -o "{}.verapdf.3a.report.xml" \;
- name: List files
run: |
find ./ -type f -name "*.verapdf.report.xml"
find ./ -type f -name "*.verapdf.3a.report.xml"
- name: Check veraPDF XML reports on errors
- name: Check veraPDF PDF/A-3a XML reports on errors
run: |
err_files_name=err.files.txt
err_files_name=err.files.3a.txt
[ -e $err_files_name ] && rm $err_files_name
for f in $(find ./ -type f -name '*.verapdf.report.xml'); do grep -l 'status=\"failed\"' $f >> $err_files_name && cat $f; done
for f in $(find ./ -type f -name '*.verapdf.3a.report.xml'); do grep -l 'status=\"failed\"' $f >> $err_files_name && cat $f; done
if [ -s $err_files_name ]; then
echo "veraPDF found PDF errors:"
echo "veraPDF found PDF/A-3a errors:"
cat $err_files_name
exit 1
fi
- name: Check PDFs for PDF/UA-1 using veraPDF
run: |
find ./ -type f -name "*.pdf" -exec curl -F "file=@{}" localhost:8080/api/validate/ua1 -H "Accept:application/xml" -o "{}.verapdf.ua1.report.xml" \;
- name: List files
run: |
find ./ -type f -name "*.verapdf.ua1.report.xml"
- name: Check veraPDF PDF/UA-1 XML reports on errors
run: |
err_files_name=err.files.ua1.txt
[ -e $err_files_name ] && rm $err_files_name
for f in $(find ./ -type f -name '*.verapdf.ua1.report.xml'); do grep -l 'status=\"failed\"' $f >> $err_files_name && cat $f; done
if [ -s $err_files_name ]; then
echo "veraPDF found PDF/UA-1 errors:"
cat $err_files_name
exit 1
fi
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ XSLT_GENERATED := xslt/iec.international-standard.xsl \
xslt/bipm.rapport.xsl \
xslt/jcgm.standard.xsl

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

Expand Down
59 changes: 58 additions & 1 deletion xslt_src/common.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -8825,6 +8825,7 @@

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

<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"/> -->

<xsl:if test="$isGenerateTableIF = 'false' and count(node()) = 0">&#xa0;</xsl:if>

</fo:block>
</fo:table-cell>
</xsl:template> <!-- td -->
Expand Down Expand Up @@ -12428,6 +12431,9 @@
<xsl:call-template name="insert_basic_link">
<xsl:with-param name="element">
<fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
<xsl:if test="$isLinkToEmbeddedFile = 'true'">
<xsl:attribute name="role">Annot</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="normalize-space(.) = ''">
<xsl:call-template name="add-zero-spaces-link-java">
Expand Down Expand Up @@ -19869,6 +19875,12 @@
<!-- Get or calculate depth of the element -->
<xsl:template name="getLevel">
<xsl:param name="depth"/>
<!-- <xsl:message>
<xsl:choose>
<xsl:when test="local-name() = 'title'">title=<xsl:value-of select="."/></xsl:when>
<xsl:when test="local-name() = 'clause'">clause/title=<xsl:value-of select="*[local-name() = 'title']"/></xsl:when>
</xsl:choose>
</xsl:message> -->
<xsl:choose>
<xsl:when test="normalize-space(@depth) != ''">
<xsl:value-of select="@depth"/>
Expand All @@ -19889,15 +19901,45 @@
<xsl:when test="ancestor::*[local-name() = 'preface']">
<xsl:value-of select="$level_total - 2"/>
</xsl:when>
<xsl:when test="ancestor::*[local-name() = 'sections'] and self::*[local-name() = 'title']">
<xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][2]/*[local-name() = 'title']/@depth)"/>
<xsl:choose>
<xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
<xsl:value-of select="number($upper_clause_depth + 1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$level_total - 2"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="ancestor::*[local-name() = 'sections']">
<xsl:value-of select="$level_total - 1"/>
<xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][1]/*[local-name() = 'title']/@depth)"/>
<xsl:choose>
<xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
<xsl:value-of select="number($upper_clause_depth + 1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$level_total - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="ancestor::*[local-name() = 'bibliography']">
<xsl:value-of select="$level_total - 1"/>
</xsl:when>
<xsl:when test="parent::*[local-name() = 'annex']">
<xsl:value-of select="$level_total - 1"/>
</xsl:when>
<xsl:when test="ancestor::*[local-name() = 'annex'] and self::*[local-name() = 'title']">
<xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][2]/*[local-name() = 'title']/@depth)"/>
<xsl:choose>
<xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
<xsl:value-of select="number($upper_clause_depth + 1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$level_total - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="ancestor::*[local-name() = 'annex']">
<xsl:value-of select="$level_total"/>
</xsl:when>
Expand Down Expand Up @@ -20609,4 +20651,19 @@
</xsl:if>
</xsl:template>

<xsl:template match="@*|node()" mode="set_table_role_skip">
<xsl:copy>
<xsl:apply-templates select="@*|node()" mode="set_table_role_skip"/>
</xsl:copy>
</xsl:template>

<xsl:template match="*[starts-with(local-name(), 'table')]" mode="set_table_role_skip">
<xsl:copy>
<xsl:apply-templates select="@*" mode="set_table_role_skip"/>
<xsl:attribute name="role">SKIP</xsl:attribute>
<xsl:apply-templates select="node()" mode="set_table_role_skip"/>
</xsl:copy>
</xsl:template>


</xsl:stylesheet>
10 changes: 6 additions & 4 deletions xslt_src/iec.international-standard.core.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -1355,9 +1355,11 @@
</xsl:template>

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

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

<xsl:template match="iec:preface//iec:clause[@type = 'toc']/iec:title" priority="3">
<fo:block font-size="12pt" text-align="center" margin-bottom="22pt" role="H1">
<fo:block font-size="12pt" text-align="center" margin-bottom="22pt">
<xsl:call-template name="addLetterSpacing">
<xsl:with-param name="text" select="java:toUpperCase(java:java.lang.String.new(.))"/>
</xsl:call-template>
Expand Down Expand Up @@ -1842,7 +1844,7 @@
<xsl:variable name="level">
<xsl:call-template name="getLevel"/>
</xsl:variable>

<xsl:variable name="font-size">
<xsl:choose>
<xsl:when test="ancestor::iec:sections and $level = 1">11pt</xsl:when>
Expand Down
39 changes: 23 additions & 16 deletions xslt_src/iso.international-standard.core.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,7 @@

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

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

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

<fo:table-row height="1.4mm" font-size="0pt">
<fo:table-cell border-bottom="{$cover_page_border}"><fo:block>&#xa0;</fo:block></fo:table-cell>
<fo:table-cell number-columns-spanned="2"><fo:block>&#xa0;</fo:block></fo:table-cell>
<fo:table-cell border-bottom="{$cover_page_border}"><fo:block>&#xa0;</fo:block></fo:table-cell>
<fo:table-cell border-bottom="{$cover_page_border}"><fo:block role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block></fo:table-cell>
<fo:table-cell number-columns-spanned="2"><fo:block role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block></fo:table-cell>
<fo:table-cell border-bottom="{$cover_page_border}"><fo:block role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row height="1.4mm" font-size="0pt">
<fo:table-cell number-columns-spanned="4"><fo:block>&#xa0;</fo:block></fo:table-cell>
<fo:table-cell number-columns-spanned="4"><fo:block role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block></fo:table-cell>
</fo:table-row>

<fo:table-row>
Expand Down Expand Up @@ -1918,7 +1918,7 @@
</fo:block-container>
</fo:table-cell>
<fo:table-cell number-columns-spanned="2" padding-left="6mm">
<fo:block margin-top="2.5mm" line-height="1.1">
<fo:block margin-top="2.5mm" line-height="1.1" role="SKIP">

<xsl:if test="not($stage-abbreviation = 'DIS' or $stage-abbreviation = 'DAMD' or $stage-abbreviation = 'DAM')">
<xsl:variable name="edition_and_date">
Expand Down Expand Up @@ -2574,7 +2574,7 @@
</fo:block>
</fo:block-container>
</fo:flow>
</xsl:otherwise>
</xsl:otherwise>
</xsl:choose>


Expand Down Expand Up @@ -2776,7 +2776,11 @@
</fo:page-sequence>
</xsl:otherwise>
</xsl:choose>
</xsl:if> <!-- $isGenerateTableIF = ' false' -->
</xsl:variable>

<xsl:apply-templates select="xalan:nodeset($fo_cover_page)" mode="set_table_role_skip"/>

</xsl:if> <!-- $isGenerateTableIF = 'false' -->
</xsl:template> <!-- END insertCoverPage -->


Expand Down Expand Up @@ -4947,6 +4951,7 @@
<xsl:template name="insertLastPage_2024">
<fo:page-sequence master-reference="last-page_2024" force-page-count="no-force">
<fo:flow flow-name="xsl-region-body">
<xsl:variable name="fo_last_page">
<fo:table table-layout="fixed" width="100%" margin-bottom="-1mm">
<xsl:call-template name="insertInterFont"/>
<fo:table-column column-width="proportional-column-width(73)"/>
Expand All @@ -4960,15 +4965,15 @@
<xsl:call-template name="insertLogoImages2024"/>
</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="2"><fo:block>&#xa0;</fo:block></fo:table-cell>
<fo:table-cell number-columns-spanned="2"><fo:block role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row height="1.4mm" font-size="0pt">
<fo:table-cell border-bottom="{$cover_page_border}"><fo:block>&#xa0;</fo:block></fo:table-cell>
<fo:table-cell number-columns-spanned="2"><fo:block>&#xa0;</fo:block></fo:table-cell>
<fo:table-cell border-bottom="{$cover_page_border}"><fo:block>&#xa0;</fo:block></fo:table-cell>
<fo:table-cell border-bottom="{$cover_page_border}"><fo:block role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block></fo:table-cell>
<fo:table-cell number-columns-spanned="2"><fo:block role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block></fo:table-cell>
<fo:table-cell border-bottom="{$cover_page_border}"><fo:block role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row height="2mm" font-size="0pt">
<fo:table-cell number-columns-spanned="4"><fo:block>&#xa0;</fo:block></fo:table-cell>
<fo:table-cell number-columns-spanned="4"><fo:block role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row height="182mm"> <!-- 174 -->
<fo:table-cell number-columns-spanned="2" display-align="after" border-right="{$cover_page_border}">
Expand Down Expand Up @@ -5004,6 +5009,8 @@
</fo:table-row>
</fo:table-body>
</fo:table>
</xsl:variable>
<xsl:apply-templates select="xalan:nodeset($fo_last_page)" mode="set_table_role_skip"/>
</fo:flow>
</fo:page-sequence>
</xsl:template> <!-- END: insertLastPage_2024 -->
Expand Down Expand Up @@ -5325,7 +5332,7 @@
</xsl:template>

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

</xsl:stylesheet>

0 comments on commit b8acbc3

Please sign in to comment.