예제 #1
0
 /// <summary>Check whether line starts with object declaration.</summary>
 /// <param name="lineTokenizer">tokenizer, built by single line.</param>
 /// <returns>object number and generation if check is successful, otherwise - null.</returns>
 public static int[] CheckObjectStart(PdfTokenizer lineTokenizer)
 {
     try {
         lineTokenizer.Seek(0);
         if (!lineTokenizer.NextToken() || lineTokenizer.GetTokenType() != PdfTokenizer.TokenType.Number)
         {
             return(null);
         }
         int num = lineTokenizer.GetIntValue();
         if (!lineTokenizer.NextToken() || lineTokenizer.GetTokenType() != PdfTokenizer.TokenType.Number)
         {
             return(null);
         }
         int gen = lineTokenizer.GetIntValue();
         if (!lineTokenizer.NextToken())
         {
             return(null);
         }
         if (!JavaUtil.ArraysEquals(Obj, lineTokenizer.GetByteContent()))
         {
             return(null);
         }
         return(new int[] { num, gen });
     }
     catch (Exception) {
     }
     // empty on purpose
     return(null);
 }
예제 #2
0
        public virtual void GetDecodedStringContentTest()
        {
            String data = "/Name1 15";
            RandomAccessSourceFactory factory = new RandomAccessSourceFactory();
            PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray(factory.CreateSource(data.GetBytes(iText.IO.Util.EncodingUtil.ISO_8859_1
                                                                                                               ))));

            tok.NextToken();
            NUnit.Framework.Assert.AreEqual("Name1", iText.IO.Util.JavaUtil.GetStringForBytes(tok.GetDecodedStringContent
                                                                                                  ()));
            tok.NextToken();
            NUnit.Framework.Assert.AreEqual("15", iText.IO.Util.JavaUtil.GetStringForBytes(tok.GetDecodedStringContent
                                                                                               ()));
            tok.NextToken();
            NUnit.Framework.Assert.AreEqual("", iText.IO.Util.JavaUtil.GetStringForBytes(tok.GetDecodedStringContent()
                                                                                         ));
        }
예제 #3
0
        public virtual void TokenValueEqualsToNullTest()
        {
            String data = "SomeString";
            RandomAccessSourceFactory factory = new RandomAccessSourceFactory();
            PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray(factory.CreateSource(data.GetBytes(iText.IO.Util.EncodingUtil.ISO_8859_1
                                                                                                               ))));

            tok.NextToken();
            NUnit.Framework.Assert.IsFalse(tok.TokenValueEqualsTo(null));
        }
예제 #4
0
        public virtual void GetDecodedStringContentHexTest()
        {
            String data = "<736f6d652068657820737472696e67>";
            RandomAccessSourceFactory factory = new RandomAccessSourceFactory();
            PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray(factory.CreateSource(data.GetBytes(iText.IO.Util.EncodingUtil.ISO_8859_1
                                                                                                               ))));

            tok.NextToken();
            NUnit.Framework.Assert.IsTrue(tok.IsHexString());
            NUnit.Framework.Assert.AreEqual("some hex string", iText.IO.Util.JavaUtil.GetStringForBytes(tok.GetDecodedStringContent
                                                                                                            ()));
        }