Beispiel #1
0
 void Initialize()
 {
     //this.info       = new PdfInfo(this);
     fontTable  = new PdfFontTable(this);
     imageTable = new PdfImageTable(this);
     trailer    = new PdfTrailer(this);
     irefTable  = new PdfReferenceTable(this);
     trailer.CreateNewDocumentIDs();
 }
Beispiel #2
0
        internal PdfDocument(Lexer lexer)
        {
            //PdfDocument.Gob.AttatchDocument(this.Handle);

            creation = DateTime.Now;
            state    = DocumentState.Imported;

            //this.info = new PdfInfo(this);
            //this.pages = new PdfPages(this);
            //this.fontTable = new PdfFontTable();
            //this.catalog = new PdfCatalog(this);
            ////this.font = new PdfFont();
            //this.objects = new PdfObjectTable(this);
            //this.trailer = new PdfTrailer(this);
            irefTable  = new PdfReferenceTable(this);
            this.lexer = lexer;
        }
Beispiel #3
0
    /// <summary>
    /// 
    /// </summary>
    PdfTrailer ReadXRefTableAndTrailer(PdfReferenceTable xrefTable)
    {
      Debug.Assert(xrefTable != null);

      Symbol symbol = ScanNextToken();
      // Is it an xref stream?
      if (symbol == Symbol.Integer)
        throw new PdfReaderException(PSSR.CannotHandleXRefStreams);
      // TODO: We have all code to handle them -> just do it
      Debug.Assert(symbol == Symbol.XRef);
      while (true)
      {
        symbol = ScanNextToken();
        if (symbol == Symbol.Integer)
        {
          int start = this.lexer.TokenToInteger;
          int length = ReadInteger();
          for (int id = start; id < start + length; id++)
          {
            int position = ReadInteger();
            int generation = ReadInteger();
            ReadSymbol(Symbol.Keyword);
            string token = lexer.Token;
            // Skip start entry
            if (id == 0)
              continue;
            // Skip unused entries.
            if (token != "n")
              continue;
            // Even it is restricted, an object can exists in more than one subsection.
            // (PDF Reference Implementation Notes 15).
            PdfObjectID objectID = new PdfObjectID(id, generation);
            // Ignore the latter one
            if (xrefTable.Contains(objectID))
              continue;
            xrefTable.Add(new PdfReference(objectID, position));
          }
        }
        else if (symbol == Symbol.Trailer)
        {
          ReadSymbol(Symbol.BeginDictionary);
          PdfTrailer trailer = new PdfTrailer(this.document);
          this.ReadDictionary(trailer, false);
          return trailer;
        }
        else
          throw new PdfReaderException(PSSR.UnexpectedToken(this.lexer.Token));
      }
    }