Example #1
0
   internal RemoteDestination(
 PdfDirectObject baseObject,
 PdfString name
 )
       : base(baseObject, name)
   {
   }
Example #2
0
 internal WidgetActions(
     Annotation parent,
     PdfDirectObject baseObject
     )
     : base(parent, baseObject)
 {
 }
Example #3
0
   internal JavaScript(
 PdfDirectObject baseObject,
 PdfString name
 )
       : base(baseObject, name)
   {
   }
Example #4
0
   //TODO:verify (colorspace is available or may be implicit?)
   protected Pattern(
 PatternColorSpace colorSpace,
 PdfDirectObject baseObject
 )
       : base(colorSpace, baseObject)
   {
   }
   public GenericOperation(
 string operator_,
 PdfDirectObject operand
 )
       : base(operator_,operand)
   {
   }
   public MarkedContentPoint(
 PdfName tag,
 PdfDirectObject properties
 )
       : base(tag, properties)
   {
   }
Example #7
0
   /**
     <summary>Instantiates a wrapper in case of reference or mutable data object.</summary>
     <param name="baseObject">PDF object backing this wrapper. MUST be a <see cref="PdfReference"/>
     everytime available.</param>
   */
   protected PdfObjectWrapper(
 PdfDirectObject baseObject
 )
   {
       BaseObject = baseObject;
         container = (baseObject != null ? baseObject.Container : null);
   }
Example #8
0
   protected LeveledColor(
 ColorSpace colorSpace,
 PdfDirectObject baseObject
 )
       : base(colorSpace, baseObject)
   {
   }
Example #9
0
 internal TilingPattern(
     PatternColorSpace colorSpace,
     PdfDirectObject baseObject
     )
     : base(colorSpace, baseObject)
 {
 }
Example #10
0
   protected DeviceColor(
 DeviceColorSpace colorSpace,
 PdfDirectObject baseObject
 )
       : base(colorSpace, baseObject)
   {
   }
Example #11
0
        protected Operation(
      string operator_,
      PdfDirectObject operand
      )
        {
            this.operator_ = operator_;

              this.operands = new List<PdfDirectObject>();
              this.operands.Add(operand);
        }
Example #12
0
        public static ILayerNode Wrap(
            PdfDirectObject baseObject
            )
        {
            if(baseObject == null)
            return null;

              PdfDataObject baseDataObject = baseObject.Resolve();
              if(baseDataObject is PdfDictionary)
            return Layer.Wrap(baseObject);
              else if(baseDataObject is PdfArray)
            return Layers.Wrap(baseObject);
              else
            throw new ArgumentException(baseDataObject.GetType().Name + " is NOT a valid layer node.");
        }
Example #13
0
 internal GoToFirstPage(
     PdfDirectObject baseObject
     )
     : base(baseObject)
 {
 }
Example #14
0
   protected SimpleFont(
 PdfDirectObject baseObject
 )
       : base(baseObject)
   {
   }
Example #15
0
 internal NamedAction(
     PdfDirectObject baseObject
     )
     : base(baseObject)
 {
 }
Example #16
0
 internal SubmitForm(
     PdfDirectObject baseObject
     )
     : base(baseObject)
 {
 }
Example #17
0
 public Names(PdfDirectObject baseObject) : base(baseObject)
 {
 }
Example #18
0
        /**
         * <summary>Parses the current PDF object [PDF:1.6:3.2].</summary>
         */
        public virtual PdfDataObject ParsePdfObject()
        {
            switch (TokenType)
            {
            case TokenTypeEnum.Integer:
                return(PdfInteger.Get((int)Token));

            case TokenTypeEnum.Name:
                return(new PdfName((string)Token, true));

            case TokenTypeEnum.DictionaryBegin:
            {
                PdfDictionary dictionary = new PdfDictionary();
                dictionary.Updateable = false;
                while (true)
                {
                    // Key.
                    MoveNext(); if (TokenType == TokenTypeEnum.DictionaryEnd)
                    {
                        break;
                    }
                    PdfName key = (PdfName)ParsePdfObject();
                    // Value.
                    MoveNext();
                    PdfDirectObject value = (PdfDirectObject)ParsePdfObject();
                    // Add the current entry to the dictionary!
                    if (dictionary.ContainsKey(key))
                    {
                        key = new PdfName(key.StringValue + "Dublicat");
                    }
                    dictionary[key] = value;
                }
                dictionary.Updateable = true;
                return(dictionary);
            }

            case TokenTypeEnum.ArrayBegin:
            {
                PdfArray array = new PdfArray();
                array.Updateable = false;
                while (true)
                {
                    // Value.
                    MoveNext(); if (TokenType == TokenTypeEnum.ArrayEnd)
                    {
                        break;
                    }
                    // Add the current item to the array!
                    array.Add((PdfDirectObject)ParsePdfObject());
                }
                array.Updateable = true;
                return(array);
            }

            case TokenTypeEnum.Literal:
                if (Token is DateTime)
                {
                    return(PdfDate.Get((DateTime)Token));
                }
                else
                {
                    return(new PdfTextString(Token == null ? null : Encoding.Pdf.Encode((string)Token)));
                }

            case TokenTypeEnum.Hex:
                return(new PdfTextString((string)Token, PdfString.SerializationModeEnum.Hex));

            case TokenTypeEnum.Real:
                return(PdfReal.Get((double)Token));

            case TokenTypeEnum.Boolean:
                return(PdfBoolean.Get((bool)Token));

            case TokenTypeEnum.Null:
                return(null);

            default:
                throw new PostScriptParseException(String.Format("Unknown type beginning: '{0}'", Token), this);
            }
        }
Example #19
0
 internal JavaScript(
     PdfDirectObject baseObject
     )
     : base(baseObject)
 {
 }
Example #20
0
 public EmbeddedFile(PdfDirectObject baseObject) : base(baseObject)
 {
 }
Example #21
0
 internal MediaScreenParameters(
     PdfDirectObject baseObject
     ) : base(baseObject)
 {
 }
Example #22
0
 internal Viability(
     PdfDirectObject baseObject
     ) : base(baseObject)
 {
 }
Example #23
0
 internal FloatingWindowParametersObject(
     PdfDirectObject baseObject
     ) : base(baseObject)
 {
 }
 private LayerDefinition(
     PdfDirectObject baseObject
     ) : base(baseObject)
 {
     Initialize();
 }
 public static LayerDefinition Wrap(
     PdfDirectObject baseObject
     )
 {
     return(baseObject != null ? new LayerDefinition(baseObject) : null);
 }
   internal FullFileSpecification(
 PdfDirectObject baseObject
 )
       : base(baseObject)
   {
   }
Example #27
0
 protected internal Widget(
     PdfDirectObject baseObject
     )
     : base(baseObject)
 {
 }
Example #28
0
        //TODO:IMPL new element constructor!

        internal ShadingPattern(PdfDirectObject baseObject) : base(baseObject)
        {
        }
Example #29
0
 //TODO:implement function creation!
 internal Type0Function(
     PdfDirectObject baseObject
     )
     : base(baseObject)
 {
 }
Example #30
0
 private ColorSpaceResources(
     PdfDirectObject baseObject,
     PdfIndirectObject container
     ) : base(baseObject, container)
 {
 }
Example #31
0
 public Page(PdfDirectObject baseObject) : base(baseObject)
 {
 }
Example #32
0
 protected override ColorSpace Wrap(
     PdfDirectObject baseObject
     )
 {
     return(ColorSpace.Wrap(baseObject, Container));
 }
Example #33
0
 public FunctionBasedShading(PdfDirectObject baseObject) : base(baseObject)
 {
 }
Example #34
0
        }  //TODO:shading types!

        #endregion
        #endregion
        #endregion

        #region dynamic
        #region constructors
        //TODO:IMPL new element constructor!

        protected Shading(PdfDirectObject baseObject) : base(baseObject)
        {
        }
Example #35
0
 internal Rectangle(
     PdfDirectObject baseObject
     )
     : base(baseObject)
 {
 }
Example #36
0
 internal Names(
     PdfDirectObject baseObject
     ) : base(baseObject)
 {
 }
Example #37
0
   public ListBox(
 PdfDirectObject baseObject
 )
       : base(baseObject)
   {
   }
Example #38
0
 public CheckBox(
     PdfDirectObject baseObject
     ) : base(baseObject)
 {
 }
Example #39
0
   protected LayerEntity(
 PdfDirectObject baseObject
 )
       : base(baseObject)
   {
   }
Example #40
0
        /**
         * <summary>Parses the current PDF object [PDF:1.6:3.2].</summary>
         */
        public PdfDataObject ParsePdfObject(
            )
        {
            /*
             * NOTE: Object parsing is intrinsically a sequential operation tied to the stream pointer.
             * Calls bound towards other classes are potentially disruptive for the predictability of
             * the position of the stream pointer, so we are forced to carefully keep track of our
             * current position in order to recover its proper state after any outbound call.
             */
            do
            {
                // Which token type?
                switch (tokenType)
                {
                case TokenTypeEnum.Integer:
                    return(new PdfInteger((int)token));

                case TokenTypeEnum.Name:
                    return(new PdfName((string)token, true));

                case TokenTypeEnum.Reference:
                    /*
                     * NOTE: Curiously, PDF references are the only primitive objects that require
                     * a file reference. That's because they deal with indirect objects, which are strongly
                     * coupled with the current state of the file: so, PDF references are the fundamental
                     * bridge between the token layer and the file layer.
                     */
                    return(new PdfReference(
                               (Reference)token,
                               file
                               ));

                case TokenTypeEnum.Literal:
                    return(new PdfTextString(
                               Encoding.Encode((string)token)
                               ));

                case TokenTypeEnum.DictionaryBegin:
                    PdfDictionary dictionary = new PdfDictionary();
                    while (true)
                    {
                        // Key.
                        MoveNext(); if (tokenType == TokenTypeEnum.DictionaryEnd)
                        {
                            break;
                        }
                        PdfName key = (PdfName)ParsePdfObject();
                        // Value.
                        MoveNext();
                        PdfDirectObject value = (PdfDirectObject)ParsePdfObject();
                        // Add the current entry to the dictionary!
                        dictionary[key] = value;
                    }

                    int oldOffset = (int)stream.Position;
                    MoveNext();
                    // Is this dictionary the header of a stream object [PDF:1.6:3.2.7]?
                    if ((tokenType == TokenTypeEnum.Keyword) &&
                        token.Equals(Keyword.BeginStream))
                    {
                        // Keep track of current position!
                        long position = stream.Position;

                        // Get the stream length!

                        /*
                         * NOTE: Indirect reference resolution is an outbound call (stream pointer hazard!),
                         * so we need to recover our current position after it returns.
                         */
                        int length = ((PdfInteger)files.File.Resolve(dictionary[PdfName.Length])).RawValue;

                        // Move to the stream data beginning!
                        stream.Seek(position); SkipEOL();

                        // Copy the stream data to the instance!
                        byte[] data = new byte[length];
                        stream.Read(data);

                        MoveNext(); // Postcondition (last token should be 'endstream' keyword).

                        Object streamType = dictionary[PdfName.Type];
                        if (PdfName.ObjStm.Equals(streamType)) // Object stream [PDF:1.6:3.4.6].
                        {
                            return(new ObjectStream(
                                       dictionary,
                                       new bytes.Buffer(data),
                                       file
                                       ));
                        }
                        else if (PdfName.XRef.Equals(streamType)) // Cross-reference stream [PDF:1.6:3.4.7].
                        {
                            return(new XRefStream(
                                       dictionary,
                                       new bytes.Buffer(data),
                                       file
                                       ));
                        }
                        else // Generic stream.
                        {
                            return(new PdfStream(
                                       dictionary,
                                       new bytes.Buffer(data)
                                       ));
                        }
                    }
                    else // Stand-alone dictionary.
                    {
                        stream.Seek(oldOffset); // Restores postcondition (last token should be the dictionary end).

                        return(dictionary);
                    }

                case TokenTypeEnum.ArrayBegin:
                    PdfArray array = new PdfArray();
                    while (true)
                    {
                        // Value.
                        MoveNext(); if (tokenType == TokenTypeEnum.ArrayEnd)
                        {
                            break;
                        }
                        // Add the current item to the array!
                        array.Add((PdfDirectObject)ParsePdfObject());
                    }
                    return(array);

                case TokenTypeEnum.Real:
                    return(new PdfReal((float)token));

                case TokenTypeEnum.Boolean:
                    return(PdfBoolean.Get((bool)token));

                case TokenTypeEnum.Date:
                    return(new PdfDate((DateTime)token));

                case TokenTypeEnum.Hex:
                    return(new PdfTextString(
                               (string)token,
                               PdfString.SerializationModeEnum.Hex
                               ));

                case TokenTypeEnum.Null:
                    return(null);

                case TokenTypeEnum.Comment:
                    // NOOP: Comments are simply ignored and skipped.
                    break;

                default:
                    throw new Exception("Unknown type: " + tokenType);
                }
            } while(MoveNext());
            return(null);
        }
Example #41
0
 internal GoToRemote(
     PdfDirectObject baseObject
     ) : base(baseObject)
 {
 }
Example #42
0
 internal ListBox(
     PdfDirectObject baseObject
     )
     : base(baseObject)
 {
 }
Example #43
0
 public static Widget Wrap(
     PdfDirectObject baseObject,
     Field field
     )
 {
     return field is CheckBox
       || field is RadioButton
     ? new DualWidget(baseObject)
     : new Widget(baseObject);
 }
Example #44
0
 internal PageElements(IWrapper <TItem> itemWrapper, PdfDirectObject baseObject, Page page)
     : base(itemWrapper, baseObject)
 {
     this.page = page;
 }
   internal ToggleVisibility(
 PdfDirectObject baseObject
 )
       : base(baseObject)
   {
   }
Example #46
0
 public Annotation(PdfDirectObject baseObject) : base(baseObject)
 {
 }
Example #47
0
 //TODO:IMPL new element constructor!
 internal ShadingPattern(
     PdfDirectObject baseObject
     )
     : base(baseObject)
 {
 }
Example #48
0
        /**
         * <summary>Wraps an annotation base object into an annotation object.</summary>
         * <param name="baseObject">Annotation base object.</param>
         * <returns>Annotation object associated to the base object.</returns>
         */
        public static Annotation Wrap(PdfDirectObject baseObject)
        {
            if (baseObject == null)
            {
                return(null);
            }
            if (baseObject.Wrapper is Annotation annotation)
            {
                return(annotation);
            }
            if (baseObject is PdfReference reference && reference.DataObject?.Wrapper is Annotation referenceAnnotation)
            {
                baseObject.Wrapper = referenceAnnotation;
                return(referenceAnnotation);
            }
            var dictionary = (PdfDictionary)baseObject.Resolve();

            if (dictionary == null)
            {
                return(null);
            }
            PdfName annotationType = (PdfName)dictionary[PdfName.Subtype];

            if (annotationType.Equals(PdfName.Text))
            {
                return(new StickyNote(baseObject));
            }
            else if (annotationType.Equals(PdfName.Link))
            {
                return(new Link(baseObject));
            }
            else if (annotationType.Equals(PdfName.FreeText))
            {
                return(new FreeText(baseObject));
            }
            else if (annotationType.Equals(PdfName.Line))
            {
                return(new Line(baseObject));
            }
            else if (annotationType.Equals(PdfName.Square))
            {
                return(new Rectangle(baseObject));
            }
            else if (annotationType.Equals(PdfName.Circle))
            {
                return(new Ellipse(baseObject));
            }
            else if (annotationType.Equals(PdfName.Polygon))
            {
                return(new Polygon(baseObject));
            }
            else if (annotationType.Equals(PdfName.PolyLine))
            {
                return(new Polyline(baseObject));
            }
            else if (annotationType.Equals(PdfName.Highlight) ||
                     annotationType.Equals(PdfName.Underline) ||
                     annotationType.Equals(PdfName.Squiggly) ||
                     annotationType.Equals(PdfName.StrikeOut))
            {
                return(new TextMarkup(baseObject));
            }
            else if (annotationType.Equals(PdfName.Stamp))
            {
                return(new Stamp(baseObject));
            }
            else if (annotationType.Equals(PdfName.Caret))
            {
                return(new Caret(baseObject));
            }
            else if (annotationType.Equals(PdfName.Ink))
            {
                return(new Scribble(baseObject));
            }
            else if (annotationType.Equals(PdfName.Popup))
            {
                return(new Popup(baseObject));
            }
            else if (annotationType.Equals(PdfName.FileAttachment))
            {
                return(new FileAttachment(baseObject));
            }
            else if (annotationType.Equals(PdfName.Sound))
            {
                return(new Sound(baseObject));
            }
            else if (annotationType.Equals(PdfName.Movie))
            {
                return(new Movie(baseObject));
            }
            else if (annotationType.Equals(PdfName.Widget))
            {
                return(new Widget(baseObject));
            }
            else if (annotationType.Equals(PdfName.Screen))
            {
                return(new Screen(baseObject));
            }
            //TODO
            //     else if(annotationType.Equals(PdfName.PrinterMark)) return new PrinterMark(baseObject);
            //     else if(annotationType.Equals(PdfName.TrapNet)) return new TrapNet(baseObject);
            //     else if(annotationType.Equals(PdfName.Watermark)) return new Watermark(baseObject);
            //     else if(annotationType.Equals(PdfName.3DAnnotation)) return new 3DAnnotation(baseObject);
            else // Other annotation type.
            {
                return(new GenericAnnotation(baseObject));
            }
        }
Example #49
0
   internal GoTo3dView(
 PdfDirectObject baseObject
 )
       : base(baseObject)
   {
   }
Example #50
0
 /**
  * <summary>Instantiates an existing external object.</summary>
  */
 protected XObject(
     PdfDirectObject baseObject
     ) : base(baseObject)
 {
 }
Example #51
0
 internal Ellipse(
     PdfDirectObject baseObject
     )
     : base(baseObject)
 {
 }
Example #52
0
 internal Line(
     PdfDirectObject baseObject
     ) : base(baseObject)
 {
 }
Example #53
0
 //TODO:IMPL new element constructor!
 protected SpecialColorSpace(
     PdfDirectObject baseObject
     )
     : base(baseObject)
 {
 }
Example #54
0
 internal PageElements(PdfDirectObject baseObject, Page page)
     : base(baseObject)
 {
     this.page = page;
 }