public virtual void ArrayCapacityHasNoLimitsTest()
        {
            PdfArray longArray = PdfACheckerTestUtils.GetLongArray(999999);

            // An exception should not be thrown as there is no limits for capacity of an array
            // in PDFA 2
            pdfA2Checker.CheckPdfObject(longArray);
        }
        private PdfName BuildLongName()
        {
            int maxAllowedLength = pdfA1Checker.GetMaxNameLength();
            int testLength       = maxAllowedLength + 1;

            NUnit.Framework.Assert.AreEqual(128, testLength);
            return(PdfACheckerTestUtils.GetLongName(testLength));
        }
        private PdfString BuildLongString()
        {
            int maxAllowedLength = pdfA1Checker.GetMaxStringLength();
            int testLength       = maxAllowedLength + 1;

            NUnit.Framework.Assert.AreEqual(65536, testLength);
            return(PdfACheckerTestUtils.GetLongString(testLength));
        }
        public virtual void ValidStreamTest()
        {
            PdfStream longStream = PdfACheckerTestUtils.GetStreamWithLongDictionary(MAX_DICTIONARY_CAPACITY);

            // No exceptions should not be thrown as the stream match the
            // limitations provided in specification
            pdfA1Checker.CheckPdfObject(longStream);
        }
        private void CheckInContentStream(PdfObject @object)
        {
            String byteContent = PdfACheckerTestUtils.GetStreamWithValue(@object);

            byte[]    newContent = byteContent.GetBytes(System.Text.Encoding.UTF8);
            PdfStream stream     = new PdfStream(newContent);

            pdfA1Checker.CheckContentStream(stream);
        }
        private void CheckInShadingPattern(PdfObject @object)
        {
            String newContentString = PdfACheckerTestUtils.GetStreamWithValue(@object);

            byte[]     newContent = newContentString.GetBytes(System.Text.Encoding.UTF8);
            PdfStream  stream     = new PdfStream(newContent);
            PdfPattern pattern    = new PdfPattern.Shading(stream);

            pdfA1Checker.CheckPdfObject(pattern.GetPdfObject());
        }
        private void CheckInFormXObject(PdfObject @object)
        {
            String newContentString = PdfACheckerTestUtils.GetStreamWithValue(@object);

            byte[]     newContent = newContentString.GetBytes(System.Text.Encoding.UTF8);
            PdfStream  stream     = new PdfStream(newContent);
            PdfXObject xobject    = new PdfFormXObject(stream);

            pdfA1Checker.CheckFormXObject(xobject.GetPdfObject());
        }
        private void CheckInTilingPattern(PdfObject @object)
        {
            String newContentString = PdfACheckerTestUtils.GetStreamWithValue(@object);

            byte[]     newContent = newContentString.GetBytes(System.Text.Encoding.UTF8);
            PdfPattern pattern    = new PdfPattern.Tiling(200, 200);

            ((PdfStream)pattern.GetPdfObject()).SetData(newContent);
            Color color = new PatternColor(pattern);

            pdfA1Checker.CheckColor(color, new PdfDictionary(), true, null);
        }
        public virtual void DictionaryCapacityHasNoLimitsTest()
        {
            PdfDictionary longDictionary = PdfACheckerTestUtils.GetLongDictionary(999999);

            // An exception should not be thrown as there is no limits for capacity of a dictionary
            // in PDFA 2
            pdfA2Checker.CheckPdfObject(longDictionary);
            PdfStream longStream = PdfACheckerTestUtils.GetStreamWithLongDictionary(999999);

            // An exception should not be thrown as there is no limits for capacity of a dictionary
            // and stream in PDFA 2
            pdfA2Checker.CheckPdfObject(longStream);
        }
 public virtual void IndependentLongStringTest()
 {
     NUnit.Framework.Assert.That(() => {
         int maxAllowedLength = pdfA2Checker.GetMaxStringLength();
         int testLength       = maxAllowedLength + 1;
         NUnit.Framework.Assert.AreEqual(testLength, 32768);
         PdfString longString = PdfACheckerTestUtils.GetLongString(testLength);
         // An exception should be thrown as provided String is longer then
         // it is allowed per specification
         pdfA2Checker.CheckPdfObject(longString);
     }
                                 , NUnit.Framework.Throws.InstanceOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.PDF_STRING_IS_TOO_LONG))
     ;
 }
        private void CheckInType3Font(PdfObject @object)
        {
            String newContentString = PdfACheckerTestUtils.GetStreamWithValue(@object);

            byte[]        newContent = newContentString.GetBytes(System.Text.Encoding.UTF8);
            PdfFont       font       = PdfFontFactory.CreateType3Font(null, true);
            PdfDictionary charProcs  = new PdfDictionary();

            charProcs.Put(PdfName.A, new PdfStream(newContent));
            PdfDictionary dictionary = font.GetPdfObject();

            dictionary.Put(PdfName.Subtype, PdfName.Type3);
            dictionary.Put(PdfName.CharProcs, charProcs);
            pdfA1Checker.CheckFont(font);
        }
 public virtual void LongStringInContentStreamTest()
 {
     NUnit.Framework.Assert.That(() => {
         pdfA2Checker.SetFullCheckMode(true);
         int maxAllowedLength = pdfA2Checker.GetMaxStringLength();
         int testLength       = maxAllowedLength + 1;
         NUnit.Framework.Assert.AreEqual(testLength, 32768);
         PdfString longString    = PdfACheckerTestUtils.GetLongString(testLength);
         String newContentString = PdfACheckerTestUtils.GetStreamWithValue(longString);
         byte[] newContent       = newContentString.GetBytes(System.Text.Encoding.UTF8);
         PdfStream stream        = new PdfStream(newContent);
         // An exception should be thrown as content stream has a string which
         // is longer then it is allowed per specification
         pdfA2Checker.CheckContentStream(stream);
     }
                                 , NUnit.Framework.Throws.InstanceOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.PDF_STRING_IS_TOO_LONG))
     ;
 }
        public virtual void ValidObjectsTest()
        {
            int    maxNameLength         = pdfA1Checker.GetMaxNameLength();
            int    maxStringLength       = pdfA1Checker.GetMaxStringLength();
            int    maxArrayCapacity      = MAX_ARRAY_CAPACITY;
            int    maxDictionaryCapacity = MAX_DICTIONARY_CAPACITY;
            long   maxIntegerValue       = pdfA1Checker.GetMaxIntegerValue();
            long   minIntegerValue       = pdfA1Checker.GetMinIntegerValue();
            double maxRealValue          = pdfA1Checker.GetMaxRealValue();

            NUnit.Framework.Assert.AreEqual(65535, maxStringLength);
            NUnit.Framework.Assert.AreEqual(127, maxNameLength);
            PdfString     longString     = PdfACheckerTestUtils.GetLongString(maxStringLength);
            PdfName       longName       = PdfACheckerTestUtils.GetLongName(maxNameLength);
            PdfArray      longArray      = PdfACheckerTestUtils.GetLongArray(maxArrayCapacity);
            PdfDictionary longDictionary = PdfACheckerTestUtils.GetLongDictionary(maxDictionaryCapacity);

            NUnit.Framework.Assert.AreEqual(2147483647, maxIntegerValue);
            NUnit.Framework.Assert.AreEqual(-2147483648, minIntegerValue);
            NUnit.Framework.Assert.AreEqual(32767, maxRealValue, 0.001);
            PdfNumber largeInteger    = new PdfNumber(maxIntegerValue);
            PdfNumber negativeInteger = new PdfNumber(minIntegerValue);
            PdfNumber largeReal       = new PdfNumber(maxRealValue - 0.001);

            PdfObject[] largeObjects = new PdfObject[] { longName, longString, longArray, longDictionary, largeInteger
                                                         , negativeInteger, largeReal };
            // No exceptions should not be thrown as all values match the
            // limitations provided in specification
            foreach (PdfObject largeObject in largeObjects)
            {
                pdfA1Checker.CheckPdfObject(largeObject);
                CheckInArray(largeObject);
                CheckInDictionary(largeObject);
                CheckInComplexStructure(largeObject);
                CheckInContentStream(largeObject);
                CheckInArrayInContentStream(largeObject);
                CheckInDictionaryInContentStream(largeObject);
                CheckInFormXObject(largeObject);
                CheckInTilingPattern(largeObject);
                CheckInType3Font(largeObject);
            }
        }
        private PdfStream BuildStreamWithLongDictionary()
        {
            int testLength = MAX_DICTIONARY_CAPACITY + 1;

            return(PdfACheckerTestUtils.GetStreamWithLongDictionary(testLength));
        }
        private PdfDictionary BuildLongDictionary()
        {
            int testLength = MAX_DICTIONARY_CAPACITY + 1;

            return(PdfACheckerTestUtils.GetLongDictionary(testLength));
        }
        private PdfArray BuildLongArray()
        {
            int testLength = MAX_ARRAY_CAPACITY + 1;

            return(PdfACheckerTestUtils.GetLongArray(testLength));
        }