Example #1
0
 /// <summary>
 /// Creates a link within the current document.
 /// </summary>
 /// <param name="rect">The link area in default page coordinates.</param>
 /// <param name="destinationPage">The one-based destination page number.</param>
 public static PdfLinkAnnotation CreateDocumentLink(PdfRectangle rect, int destinationPage)
 {
   PdfLinkAnnotation link = new PdfLinkAnnotation();
   link.linkType = PdfLinkAnnotation.LinkType.Document;
   link.Rectangle = rect;
   link.destPage = destinationPage;
   return link;
 }
        /// <summary>
        /// Creates a link to the web.
        /// </summary>
        public static PdfLinkAnnotation CreateWebLink(PdfRectangle rect, string url)
        {
            PdfLinkAnnotation link = new PdfLinkAnnotation();

            link.linkType  = PdfLinkAnnotation.LinkType.Web;
            link.Rectangle = rect;
            link.url       = url;
            return(link);
        }
        /// <summary>
        /// Creates a link within the current document.
        /// </summary>
        /// <param name="rect">The link area in default page coordinates.</param>
        /// <param name="destinationPage">The one-based destination page number.</param>
        public static PdfLinkAnnotation CreateDocumentLink(PdfRectangle rect, int destinationPage)
        {
            PdfLinkAnnotation link = new PdfLinkAnnotation();

            link.linkType  = PdfLinkAnnotation.LinkType.Document;
            link.Rectangle = rect;
            link.destPage  = destinationPage;
            return(link);
        }
Example #4
0
        /// <summary>
        /// Creates a link to an embedded document in another document.
        /// </summary>
        /// <param name="rect">The link area in default page coordinates.</param>
        /// <param name="documentPath">The path to the target document.</param>
        /// <param name="destinationPath">The path to the named destination through the embedded documents in the target document.
        /// The path is separated by '\' and the last segment is the name of the named destination.
        /// The other segments describe the route from the root document to the embedded document.
        /// Each segment name refers to a child with this name in the EmbeddedFiles name dictionary.</param>
        /// <param name="newWindow">True, if the destination document shall be opened in a new window.
        /// If not set, the viewer application should behave in accordance with the current user preference.</param>
        public static PdfLinkAnnotation CreateEmbeddedDocumentLink(PdfRectangle rect, string documentPath, string destinationPath, bool?newWindow = null)
        {
            PdfLinkAnnotation link = new PdfLinkAnnotation();

            link._linkType = LinkType.NamedDestination;
            link.Rectangle = rect;
            link._action   = PdfEmbeddedGoToAction.CreatePdfEmbeddedGoToAction(documentPath, destinationPath, newWindow);
            return(link);
        }
Example #5
0
        /// <summary>
        /// Creates a link within the current document using a named destination.
        /// </summary>
        /// <param name="rect">The link area in default page coordinates.</param>
        /// <param name="destinationName">The named destination's name.</param>
        public static PdfLinkAnnotation CreateDocumentLink(PdfRectangle rect, string destinationName)
        {
            PdfLinkAnnotation link = new PdfLinkAnnotation();

            link._linkType = LinkType.NamedDestination;
            link.Rectangle = rect;
            link._action   = PdfGoToAction.CreateGoToAction(destinationName);
            return(link);
        }
        /// <summary>
        /// Creates a link to a file.
        /// </summary>
        public static PdfLinkAnnotation CreateFileLink(PdfRectangle rect, string fileName)
        {
            PdfLinkAnnotation link = new PdfLinkAnnotation();

            link.linkType = PdfLinkAnnotation.LinkType.File;
            // TODO: Adjust bleed box here (if possible)
            link.Rectangle = rect;
            link.url       = fileName;
            return(link);
        }
Example #7
0
        /// <summary>
        /// Creates a link within the current document.
        /// </summary>
        /// <param name="rect">The link area in default page coordinates.</param>
        /// <param name="destinationPage">The one-based destination page number.</param>
        public static PdfLinkAnnotation CreateDocumentLink(PdfRectangle rect, int destinationPage)
        {
            if (destinationPage < 1)
                throw new ArgumentException("Invalid destination page in call to CreateDocumentLink: page number is one-based and must be 1 or higher.", "destinationPage");

            PdfLinkAnnotation link = new PdfLinkAnnotation();
            link._linkType = LinkType.Document;
            link.Rectangle = rect;
            link._destPage = destinationPage;
            return link;
        }
Example #8
0
        /// <summary>
        /// Creates a link within the current document.
        /// </summary>
        /// <param name="rect">The link area in default page coordinates.</param>
        /// <param name="destinationPage">The one-based destination page number.</param>
        public static PdfLinkAnnotation CreateDocumentLink(PdfRectangle rect, int destinationPage)
        {
            if (destinationPage < 1)
            {
                throw new ArgumentException("Invalid destination page in call to CreateDocumentLink: page number is one-based and must be 1 or higher.", "destinationPage");
            }

            PdfLinkAnnotation link = new PdfLinkAnnotation();

            link._linkType = LinkType.Document;
            link.Rectangle = rect;
            link._destPage = destinationPage;
            return(link);
        }
Example #9
0
 /// <summary>
 /// Gets the <see cref="PdfSharp.Pdf.Annotations.PdfAnnotation"/> at the specified index.
 /// </summary>
 public PdfAnnotation this[int index]
 {
     get
     {
         PdfReference  iref;
         PdfDictionary dict;
         PdfItem       item = Elements[index];
         if ((iref = item as PdfReference) != null)
         {
             Debug.Assert(iref.Value is PdfDictionary, "Reference to dictionary expected.");
             dict = (PdfDictionary)iref.Value;
         }
         else
         {
             Debug.Assert(item is PdfDictionary, "Dictionary expected.");
             dict = (PdfDictionary)item;
         }
         PdfAnnotation annotation = dict as PdfAnnotation;
         if (annotation == null)
         {
             if (dict.Elements.GetString(PdfAnnotation.Keys.Subtype) == "/Widget")
             {
                 annotation = new PdfWidgetAnnotation(dict);
             }
             else if (dict.Elements.GetString(PdfAnnotation.Keys.Subtype) == "/Link")
             {
                 annotation = new PdfLinkAnnotation(dict);
             }
             else if (dict.Elements.GetString(PdfAnnotation.Keys.Subtype) == "/Stamp")
             {
                 annotation = new PdfRubberStampAnnotation(dict);
             }
             else if (dict.Elements.GetString(PdfAnnotation.Keys.Subtype) == "/Text")
             {
                 annotation = new PdfTextAnnotation(dict);
             }
             else
             {
                 annotation = new PdfGenericAnnotation(dict);
             }
             if (iref == null)
             {
                 Elements[index] = annotation;
             }
         }
         return(annotation);
     }
 }
Example #10
0
 /// <summary>
 /// Creates a link to the web.
 /// </summary>
 public static PdfLinkAnnotation CreateWebLink(PdfRectangle rect, string url)
 {
   PdfLinkAnnotation link = new PdfLinkAnnotation();
   link.linkType = PdfLinkAnnotation.LinkType.Web;
   link.Rectangle = rect;
   link.url = url;
   return link;
 }
Example #11
0
 /// <summary>
 /// Creates a link to a file.
 /// </summary>
 public static PdfLinkAnnotation CreateFileLink(PdfRectangle rect, string fileName)
 {
   PdfLinkAnnotation link = new PdfLinkAnnotation();
   link.linkType = PdfLinkAnnotation.LinkType.File;
   // TODO: Adjust bleed box here (if possible)
   link.Rectangle = rect;
   link.url = fileName;
   return link;
 }
 /// <summary>
 /// Creates a link to a file.
 /// </summary>
 public static PdfLinkAnnotation CreateFileLink(PdfRectangle rect, string fileName)
 {
   PdfLinkAnnotation link = new PdfLinkAnnotation();
   link.linkType = PdfLinkAnnotation.LinkType.File;
   link.Rectangle = rect;
   link.url = fileName;
   return link;
 }