<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profile xmlns="http://www.verapdf.org/ValidationProfile" model="org.verapdf.model.PDFA1a">
    <name>File structure profile</name>
    <description>Requirements of PDF/A standard for File structure subsection</description>
    <creator>veraPDF Consortium</creator>
    <created>2015-08-25T15-55-47Z+03</created>
    <hash>sha-1 hash code</hash>
    <rules>
        <rule id="6-1-10-t01" object="CosStream">
			<description>The LZWDecode filter shall not be permitted</description>
			<test>filters == null || filters.indexOf("LZWDecode") == -1</test>
			<error>
				<message>LZW compression is used</message>
			</error>
			<reference>
				<specification>ISO19005-1</specification>
				<clause>6.1.10</clause>
			</reference>
		</rule>
        <rule id="6-1-10-t02" object="PDInlineImage">
			<description>The LZWDecode filter shall not be permitted</description>
			<test>F == null || F.indexOf("LZW") == -1</test>
			<error>
				<message>LZW compression is used in the inline image</message>
			</error>
			<reference>
				<specification>ISO19005-1</specification>
				<clause>6.1.10</clause>
			</reference>
		</rule>
        <rule id="6-1-11-t02" object="CosDocument">
			<description>A file's name dictionary, as defined in PDF Reference 3.6.3, shall not contain the EmbeddedFiles key</description>
			<test>EmbeddedFiles_size == 0</test>
			<error>
				<message>The document contains embedded files (EmbeddedFiles key is present in the file's name dictionary)</message>
			</error>
			<reference>
				<specification>ISO19005-1</specification>
				<clause>6.1.7</clause>
				<reference>
					<specification>PDF 1.4 Reference</specification>
				<clause>3.6.3</clause>
			</reference>
			</reference>
		</rule>
        <rule id="6-1-12-t01" object="CosInteger">
            <description>Largest Integer value is 2,147,483,647. Smallest integer value is -2,147,483,648</description>
            <test>(intValue &lt;= 2147483647) &amp;&amp; (intValue &gt;= -2147483648)</test>
            <error>
                <message>Integer value out of range</message>
            </error>
            <reference>
                <specification>ISO19005-1</specification>
                <clause>6.1.12</clause>
				<reference>
					<specification>PDF Reference 1.4</specification>
					<clause>Table C.1</clause>
				</reference>
            </reference>
        </rule>
        <rule id="6-1-12-t02" object="CosReal">
            <description>Absolute real value must be less than or equal to 32767.0</description>
            <test>(realValue &gt;= -32767.0) &amp;&amp; (realValue &lt;= 32767.0)</test>
            <error>
                <message>Real value out of range</message>
            </error>
            <reference>
                <specification>ISO19005-1</specification>
                <clause>6.1.12</clause>
				<reference>
					<specification>PDF Reference 1.4</specification>
					<clause>Table C.1</clause>
				</reference>
            </reference>
        </rule>
        <rule id="6-1-12-t03" object="CosString">
            <description>Maximum length of a string (in bytes) is 65535</description>
            <test>value.length() &lt; 65536</test>
            <error>
                <message>Maximum length of a String (65535) exceeded</message>
            </error>
            <reference>
                <specification>ISO19005-1</specification>
                <clause>6.1.12</clause>
				<reference>
					<specification>PDF Reference 1.4</specification>
					<clause>Table C.1</clause>
				</reference>
            </reference>
        </rule>
        <rule id="6-1-12-t04" object="CosName">
            <description>Maximum length of a name (in bytes) is 127</description>
            <test>origLength &lt;= 127</test>
            <error>
                <message>Maximum length of a Name (127) exceeded</message>
				<argument>origLength</argument>
            </error>
            <reference>
                <specification>ISO19005-1</specification>
                <clause>6.1.12</clause>
				<reference>
					<specification>PDF Reference 1.4</specification>
					<clause>Table C.1</clause>
				</reference>
            </reference>
        </rule>
        <rule id="6-1-12-t05" object="CosArray">
            <description>Maximum capacity of an array (in elements) is 8191</description>
            <test>size &lt;= 8191</test>
            <error>
                <message>Maximum capacity of an array (8191) exceeded</message>
            </error>
            <reference>
                <specification>ISO19005-1</specification>
                <clause>6.1.12</clause>
				<reference>
					<specification>PDF Reference 1.4</specification>
					<clause>Table C.1</clause>
				</reference>
            </reference>
        </rule>
        <rule id="6-1-12-t06" object="CosDict">
            <description>Maximum capacity of a dictionary (in entries) is 4095</description>
            <test>size &lt;= 4095</test>
            <error>
                <message>Maximum capacity of a dictionary (4095) exceeded</message>
            </error>
            <reference>
                <specification>ISO19005-1</specification>
                <clause>6.1.12</clause>
				<reference>
					<specification>PDF Reference 1.4</specification>
					<clause>Table C.1</clause>
				</reference>
            </reference>
        </rule>
        <rule id="6-1-12-t07" object="CosDocument">
            <description>Maximum number of indirect objects in a PDF file is 8,388,607</description>
            <test>nrIndirects &lt;= 8388607</test>
            <error>
                <message>Maximum number of indirect objects (8,388,607) in a PDF file exceeded</message>
            </error>
            <reference>
                <specification>ISO19005-1</specification>
                <clause>6.1.12</clause>
				<reference>
					<specification>PDF Reference 1.4</specification>
					<clause>Table C.1</clause>
				</reference>
            </reference>
        </rule>
        <rule id="6-1-12-t08" object="Op_q_gsave">
            <description>Maximum depth of graphics state nesting by q and Q operators is 28</description>
            <test>nestingLevel &lt;= 28</test>
            <error>
                <message>Maximum depth of graphics state nesting (q and Q operators) is exceeded</message>
            </error>
            <reference>
                <specification>ISO19005-1</specification>
                <clause>6.1.12</clause>
				<reference>
					<specification>PDF Reference 1.4</specification>
					<clause>Table C.1</clause>
				</reference>
            </reference>
        </rule>
        <rule id="6-1-12-t09" object="PDDeviceN">
            <description>Maximum number of DeviceN components is 8</description>
            <test>nrComponents &lt;= 8</test>
            <error>
                <message>Maximum number of DeviceN components is exceeded</message>
            </error>
            <reference>
                <specification>ISO19005-1</specification>
                <clause>6.1.12</clause>
				<reference>
					<specification>PDF Reference 1.4</specification>
					<clause>Table C.1</clause>
				</reference>
            </reference>
        </rule>
        <rule id="6-1-12-t10" object="CIDGlyph">
            <description>Maximum value of a CID (character identifier) is 65,535</description>
            <test>CID &lt;= 65535</test>
            <error>
                <message>Maximum value of a CID (65,535) is exceeded</message>
            </error>
            <reference>
                <specification>ISO19005-1</specification>
                <clause>6.1.12</clause>
				<reference>
					<specification>PDF Reference 1.4</specification>
					<clause>Table C.1</clause>
				</reference>
            </reference>
        </rule>
        <rule id="6-1-13-t01" object="CosDocument">
			<description>The document catalog dictionary shall not contain a key with the name OCProperties</description>
			<test>isOptionalContentPresent == false</test>
			<error>
				<message>The document catalog dictionary contains the OCProperties entry</message>
			</error>
			<reference>
				<specification>ISO19005-1</specification>
				<clause>6.1.13</clause>
			</reference>
		</rule>
        <rule id="6-1-2-t01" object="CosDocument">
			<description>The % character of the file header shall occur at byte offset 0 of the file. 
			The first line of a PDF file is a header identifying the version of the PDF specification to which the file conforms</description>
			<test>pdfHeaderCompliesPDFA</test>
			<error>
				<message>File header does not start at byte offset 0 or does not correctly identify the version of the PDF document</message>
			</error>
			<reference>
				<specification>ISO19005-1</specification>
				<clause>6.1.2</clause>
				<reference>
					<specification>PDF 1.4 Reference</specification>
					<clause>3.4.1</clause>
				</reference>			
			</reference>
		</rule>
        <rule id="6-1-2-t02" object="CosDocument">
			<description>The file header line shall be immediately followed by a comment consisting of a % character followed by at 
			least four characters, each of whose encoded byte values shall have a decimal value greater than 127</description>
			<test>binaryHeaderComplyPDFA</test>
			<error>
				<message>Binary comment in the file header is missing or does not comply PDF/A requirements</message>
			</error>
			<reference>
				<specification>ISO19005-1</specification>
				<clause>6.1.2</clause>
			</reference>
		</rule>
        <rule id="6-1-3-t01" object="CosDocument">
			<description>The file trailer dictionary shall contain the ID keyword. The file trailer referred to is either the last trailer dictionary in a PDF file,
			as described in PDF Reference 3.4.4 and 3.4.5, or the first page trailer in a linearized PDF file, as described in PDF Reference F.2</description>
			<test>(isLinearized == true &amp;&amp; firstPageID != null) || ((isLinearized != true) &amp;&amp; lastID != null)</test>
			<error>
				<message>Missing ID in the document trailer</message>
			</error>
			<reference>
				<specification>ISO19005-1:2005</specification>
				<clause>6.1.3</clause>
			</reference>
		</rule>
        <rule id="6-1-3-t02" object="CosTrailer">
			<description>The keyword Encrypt shall not be used in the trailer dictionary</description>
			<test>isEncrypted != true</test>
			<error>
				<message>Encrypt keyword is present in the trailer dictionary</message>
			</error>
			<reference>
				<specification>ISO19005-1:2005</specification>
				<clause>6.1.3</clause>
			</reference>
		</rule>
        <rule id="6-1-3-t03" object="CosDocument">
			<description>No data shall follow the last end-of-file marker except a single optional end-of-line marker.</description>
			<test>eofCompliesPDFA</test>
			<error>
				<message>Data is present after the last end-of-file marker</message>
			</error>
			<reference>
				<specification>ISO19005-1:2005</specification>
				<clause>6.1.3</clause>
			</reference>
		</rule>
        <rule id="6-1-3-t04" object="CosDocument">
			<description>In a linearized PDF, if the ID keyword is present in both the first page trailer dictionary 
			and the last trailer dictionary, the value to both instances of the ID keyword shall be identical</description>
			<test>(isLinearized != true)|| lastID == null || (firstPageID == lastID)</test>
			<error>
				<message>Last ID is present in the Linearized PDF and does not match the first page ID</message>
			</error>
			<reference>
				<specification>ISO 19005-1:2005/Cor.2:2011</specification>
				<clause>6.1.3</clause>
			</reference>
		</rule>
        <rule id="6-1-4-t01" object="CosXRef">
			<description>In a cross reference subsection header the starting object number and the range shall be separated by a single SPACE character (20h)</description>
			<test>xrefHeaderSpacingsComplyPDFA</test>
			<error>
				<message>Spacings of subsection headers in the cross reference table do not comply PDF/A specification</message>
			</error>
			<reference>
				<specification>ISO19005-1:2005</specification>
				<clause>6.1.4</clause>
			</reference>
		</rule>
        <rule id="6-1-4-t02" object="CosXRef">
			<description>The xref keyword and the cross reference subsection header shall be separated by a single EOL marker</description>
			<test>xrefEOLMarkersComplyPDFA</test>
			<error>
				<message>Spacings after the 'xref' keyword iin the cross reference table do not comply PDF/A specification</message>
			</error>
			<reference>
				<specification>ISO19005-1:2005</specification>
				<clause>6.1.4</clause>
			</reference>
		</rule>
        <rule id="6-1-6-t01" object="CosString">
			<description>Hexadecimal strings shall contain an even number of non-white-space characters</description>
			<test>(isHex != true) || hexCount % 2 == 0</test>
			<error>
				<message>Hexadecimal string contains odd number of non-white-space characters</message>
			</error>
			<reference>
				<specification>ISO19005-1</specification>
				<clause>6.1.6</clause>
			</reference>
		</rule>
        <rule id="6-1-6-t02" object="CosString">
			<description>All non-white-space characters in hexadecimal strings shall be in the range 0 to 9, A to F or a to f</description>
			<test>(isHex != true) || isHexSymbols</test>
			<error>
				<message>Hexadecimal string contains non-white-space characters outside the range 0 to 9, A to F or a to f</message>
			</error>
			<reference>
				<specification>ISO19005-1</specification>
				<clause>6.1.6</clause>
			</reference>
		</rule>
        <rule id="6-1-7-t01" object="CosStream">
			<description>The value of the Length key specified in the stream dictionary shall match the number of bytes in the file
			following the LINE FEED character after the stream keyword and preceding the EOL marker before the endstream keyword</description>
			<test>isLengthCorrect</test>
			<error>
				<message>Actual length of the stream does not match the value of the Length key in the Stream dictionary</message>
			</error>
			<reference>
				<specification>ISO19005-1</specification>
				<clause>6.1.7</clause>
			</reference>
		</rule>
        <rule id="6-1-7-t02" object="CosStream">
			<description>The stream keyword shall be followed either by a CARRIAGE RETURN (0Dh) and LINE FEED (0Ah) character sequence
			or by a single LINE FEED character. The endstream keyword shall be preceded by an EOL marker</description>
			<test>spacingCompliesPDFA</test>
			<error>
				<message>Spacings of keywords 'stream' and 'endstream' do not comply PDF/A specification</message>
			</error>
			<reference>
				<specification>ISO19005-1</specification>
				<clause>6.1.7</clause>
			</reference>
		</rule>
        <rule id="6-1-7-t03" object="CosStream">
			<description>A stream object dictionary shall not contain the F, FFilter, or FDecodeParms keys</description>
			<test>F == null &amp;&amp; FFilter == null &amp;&amp; FDecodeParms == null</test>
			<error>
				<message>A stream object dictionary contains one of the F, FFilter, or FDecodeParms keys</message>
			</error>
			<reference>
				<specification>ISO19005-1</specification>
				<clause>6.1.7</clause>
			</reference>
			<reference>
				<specification>19005-1:2005/Cor.2:2011</specification>
				<clause>6.1.7</clause>
			</reference>
		</rule>
        <rule id="6-1-8-t01" object="CosIndirect">
			<description>The object number and generation number shall be separated by a single white-space character. The generation number and obj keyword 
	shall be separated by a single white-space character. The object number and endobj keyword shall each be preceded by an EOL marker. The obj and endobj
	keywords shall each be followed by an EOL marker.</description>
			<test>spacingCompliesPDFA</test>
			<error>
				<message>Spacings of object number and generation number or keywords 'obj' and 'endobj' do not comply PDF/A specification</message>
			</error>
			<reference>
				<specification>ISO19005-1</specification>
				<clause>6.1.8</clause>
			</reference>
		</rule>
    </rules>
</profile>
