Пример #1
0
        /// <summary>
        /// Closes a previous artefact registration popping it off the stack of it's name tree collection
        /// </summary>
        /// <param name="registration"></param>
        public void Close(object registration)
        {
            PDFCategorisedNameTree col;

            if (registration is ICategorisedArtefactNamesEntry)
            {
                ICategorisedArtefactNamesEntry catEntry = (ICategorisedArtefactNamesEntry)registration;
                if (_dictionary.TryGetValue(catEntry.NamesCategory, out col))
                {
                    col.Pop(catEntry.FullName, catEntry);
                }
                else
                {
                    throw new PDFException(catEntry.NamesCategory + " Names dictionary entry has not previously been registered");
                }
            }
            else if (registration is PDFDestination) //Default is Destination as this was generated before the support for other name trees
            {
                PDFDestination dest = (PDFDestination)registration;
                if (_dictionary.TryGetValue(DestinationsName, out col))
                {
                    col.Pop(dest.FullName, dest);
                }
                else
                {
                    throw new PDFException("Destinations Names dictionary entry has not previously been registered");
                }
            }
            else
            {
                throw new PDFException("Unknown Artefact entry for the Names dictionary");
            }
        }
        /// <summary>
        /// Registers the actual destination and returns the destination
        /// </summary>
        /// <param name="dest"></param>
        /// <returns></returns>
        internal protected virtual PDFDestination RegisterDestination(PDFDestination dest)
        {
            if (null == dest)
            {
                throw new ArgumentNullException("dest");
            }

            _dests[dest.FullName] = dest;
            return(dest);
        }
        //
        // methods
        //

        #region object IArtefactCollection.Register(IArtefactEntry entry)

        /// <summary>
        /// Implmentation of the IArtefactCollection Register method, to ensure that all names are included in the final PDF docucment. Calls RegisterDestination
        /// </summary>
        /// <param name="entry"></param>
        /// <returns></returns>
        object IArtefactCollection.Register(IArtefactEntry entry)
        {
            if (entry is ICategorisedArtefactNamesEntry)
            {
                ICategorisedArtefactNamesEntry catNameEntry = (ICategorisedArtefactNamesEntry)entry;
            }
            PDFDestination dest = (PDFDestination)entry;

            return(this.RegisterDestination(dest));
        }
        /// <summary>
        /// Writes a single destination
        /// </summary>
        /// <param name="context"></param>
        /// <param name="writer"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        internal bool WriteDestination(PDFRenderContext context, PDFWriter writer, string name)
        {
            PDFDestination dest = _dests[name];

            writer.BeginArrayEntry();
            writer.WriteStringLiteral(name);
            writer.EndArrayEntry();

            writer.BeginArrayEntry();
            dest.OutputToPDF(context, writer);
            writer.EndArrayEntry();
            writer.WriteLine();
            return(true);
        }
Пример #5
0
 /// <summary>
 /// Creates a new destination action.
 /// </summary>
 /// <param name="owner">The owner of this action</param>
 /// <param name="action">The action type to perform - must be LinkAction.Destination</param>
 /// <param name="destination">The destination to navigate to.</param>
 public PDFDestinationAction(Component owner, LinkAction action, PDFDestination destination)
     : base(owner, action)
 {
     this.Destination = destination;
     AssertIsDestination(action);
 }
 /// <summary>
 /// Performs any required closure
 /// </summary>
 /// <param name="dest"></param>
 protected virtual void Close(PDFDestination dest)
 {
     //Do nothing
 }
        /// <summary>
        /// Implmentation of the IArtefactCollection Close method.
        /// </summary>
        /// <param name="result"></param>
        void IArtefactCollection.Close(object result)
        {
            PDFDestination dest = result as PDFDestination;

            this.Close(dest);
        }