Skip to content

Use VeraPDF to validate PDF/A compliance during testing #788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
# For debugging issues
- name: Archive test results
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-run-output-${{ matrix.php-version }}-${{ matrix.os }}
retention-days: 1
Expand Down
14 changes: 7 additions & 7 deletions examples/example_065.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Last Update : 2013-05-14
//
// Description : Example 065 for TCPDF class
// Creates an example PDF/A-1b document using TCPDF
// Creates an example PDF/A-3b document using TCPDF
//
// Author: Nicola Asuni
//
Expand All @@ -17,20 +17,20 @@
//============================================================+

/**
* Creates an example PDF/A-1b document using TCPDF
* Creates an example PDF/A-3b document using TCPDF
* @package com.tecnick.tcpdf
* @abstract TCPDF - Example: PDF/A-1b mode
* @abstract TCPDF - Example: PDF/A-3b mode
* @author Nicola Asuni
* @since 2011-09-28
* @group A-1b
* @group A-3b
* @group pdf
*/

// Include the main TCPDF library (search for installation path).
require_once('tcpdf_include.php');

// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false, true);
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false, 3);

// set document information
$pdf->setCreator(PDF_CREATOR);
Expand Down Expand Up @@ -80,8 +80,8 @@

// Set some content to print
$html = <<<EOD
<h1>Example of <a href="http://www.tcpdf.org" style="text-decoration:none;background-color:#CC0000;color:black;">&nbsp;<span style="color:black;">TC</span><span style="color:white;">PDF</span>&nbsp;</a> document in <span style="background-color:#99ccff;color:black;"> PDF/A-1b </span> mode.</h1>
<i>This document conforms to the standard <b>PDF/A-1b (ISO 19005-1:2005)</b>.</i>
<h1>Example of <a href="http://www.tcpdf.org" style="text-decoration:none;background-color:#CC0000;color:black;">&nbsp;<span style="color:black;">TC</span><span style="color:white;">PDF</span>&nbsp;</a> document in <span style="background-color:#99ccff;color:black;"> PDF/A-3b </span> mode.</h1>
<i>This document conforms to the standard <b>PDF/A-3b (ISO 19005-3:2012)</b>.</i>
<p>Please check the source code documentation and other examples for further information (<a href="http://www.tcpdf.org">http://www.tcpdf.org</a>).</p>
<p style="color:#CC0000;">TO IMPROVE AND EXPAND TCPDF I NEED YOUR SUPPORT, PLEASE <a href="http://sourceforge.net/donate/index.php?group_id=128076">MAKE A DONATION!</a></p>
EOD;
Expand Down
14 changes: 7 additions & 7 deletions examples/example_066.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
/**
* Example 066 for TCPDF library
*
* @description Creates an example PDF/A-1b document using TCPDF
* @description Creates an example PDF/A-3b document using TCPDF
* @author Nicola Asuni - Tecnick.com LTD <[email protected]>
* @license LGPL-3.0
*/

/**
* Creates an example PDF/A-1b document using TCPDF
* Creates an example PDF/A-3b document using TCPDF
*
* @abstract TCPDF - Example: PDF/A-1b mode
* @abstract TCPDF - Example: PDF/A-3b mode
* @author Nicola Asuni
* @since 2021-03-26
* @group A-1b
* @group A-3b
* @group pdf
*/

// Include the main TCPDF library (search for installation path).
require_once('tcpdf_include.php');

// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false, true);
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false, 3);

// set document information
$pdf->setCreator(PDF_CREATOR);
Expand Down Expand Up @@ -73,8 +73,8 @@

// Set some content to print
$html = <<<HTML
<h1>Example of <a href="http://www.tcpdf.org" style="text-decoration:none;background-color:#CC0000;color:black;">&nbsp;<span style="color:black;">TC</span><span style="color:white;">PDF</span>&nbsp;</a> document in <span style="background-color:#99ccff;color:black;"> PDF/A-1b </span> mode.</h1>
<i>This document conforms to the standard <b>PDF/A-1b (ISO 19005-1:2005)</b>.</i>
<h1>Example of <a href="http://www.tcpdf.org" style="text-decoration:none;background-color:#CC0000;color:black;">&nbsp;<span style="color:black;">TC</span><span style="color:white;">PDF</span>&nbsp;</a> document in <span style="background-color:#99ccff;color:black;"> PDF/A-3b </span> mode.</h1>
<i>This document conforms to the standard <b>PDF/A-3b (ISO 19005-3:2012)</b>.</i>
<p>Please check the source code documentation and other examples for further information (<a href="http://www.tcpdf.org">http://www.tcpdf.org</a>).</p>
HTML;

Expand Down
2 changes: 1 addition & 1 deletion examples/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<li>XObject Templates: [<a href="example_062.php" title="PDF [new window]" target="_blank">PDF</a>]</li>
<li>Text stretching and spacing (tracking/kerning): [<a href="example_063.php" title="PDF [new window]" target="_blank">PDF</a>]</li>
<li>No-write page regions: [<a href="example_064.php" title="PDF [new window]" target="_blank">PDF</a>]</li>
<li>PDF/A-1b (ISO 19005-1:2005) document: [<a href="example_065.php" title="PDF [new window]" target="_blank">PDF</a>]</li>
<li>PDF/A-3b (ISO 19005-3:2012) document: [<a href="example_065.php" title="PDF [new window]" target="_blank">PDF</a>]</li>
<li>Using WriteHTMLCell: [<a href="example_066.php" title="PDF [new window]" target="_blank">PDF</a>]</li>
<li>Shorthand border styles including !important: [<a href="example_067.php" title="PDF [new window]" target="_blank">PDF</a>]</li>
</ol>
Expand Down
12 changes: 12 additions & 0 deletions tests/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@ for file in $EXAMPLE_FILES; do
FAILED_FLAG=1
echo "Generated-invalid-file: $file"
fi
if [ "$file" = "examples/example_065.php" ] || [ "$file" = "examples/example_066.php" ]; then
VALIDATION_OUTPUT="$(docker run -v $TEMP_FOLDER:/data --quiet --rm -w /data/ pdfix/verapdf-validation:latest validate --format 'json' -i 'output.pdf')"
VALIDATION_RESULT="$(echo $VALIDATION_OUTPUT | jq '.report.jobs[0].validationResult[0].compliant')"
if [ "$VALIDATION_RESULT" = "false" ]; then
FAILED_FLAG=1
echo "Generated pdf file failed validation: $file"
echo $VALIDATION_OUTPUT
else
VALIDATION_PROFILE="$(echo $VALIDATION_OUTPUT | jq '.report.jobs[0].validationResult[0].profileName')"
echo "Pdf validated with $VALIDATION_PROFILE: $file"
fi
fi
else
FAILED_FLAG=1
echo "File-run-failed: $file"
Expand Down