public static void Run()
 {
     try
     {
         // ExStart:UpdateLinks
         // The path to the documents directory.
         string dataDir = RunExamples.GetDataDir_AsposePdf_LinksActions();
         // Load the PDF file
         Document doc = new Document(dataDir + "UpdateLinks.pdf");
         // Get the first link annotation from first page of document
         LinkAnnotation linkAnnot = (LinkAnnotation)doc.Pages[1].Annotations[1];
         // Modification link: change link destination
         GoToAction goToAction = (GoToAction)linkAnnot.Action;
         // Specify the destination for link object
         // The first parameter is document object, second is destination page number.
         // The 5ht argument is zoom factor when displaying the respective page. When using 2, the page will be displayed in 200% zoom
         goToAction.Destination = new Aspose.Pdf.Annotations.XYZExplicitDestination(1, 1, 2, 2);
         dataDir = dataDir + "PDFLINK_Modified_UpdateLinks_out_.pdf";
         // Save the document with updated link
         doc.Save(dataDir);
         // ExEnd:UpdateLinks
         Console.WriteLine("\nLinks updated successfully.\nFile saved at " + dataDir);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Beispiel #2
0
 private void AddActions()
 {
     foreach (Transform t in wayPoints)
     {
         GoToAction newAction = Owner.gameObject.AddComponent <GoToAction>();
         newAction.target           = t;
         newAction.actionPriority   = 0;
         newAction.distanceToTarget = 0.4f;
         Owner.ScheduleNewAction(newAction);
     }
 }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments();

            // instantiate new Document object
            Document doc = new Document(dataDir + "Zoomed_pdf.pdf");

            // create GoToAction object
            GoToAction action = doc.OpenAction as GoToAction;

            // get the Zoom factor of PDF file
            System.Console.WriteLine((action.Destination as XYZExplicitDestination).Zoom); // Document zoom value;
        }
Beispiel #4
0
    public override void ApplyBehaviour()
    {
        GoToAction newAction = Owner.gameObject.AddComponent <GoToAction>();

        newAction.target           = smartObject.transform;
        newAction.actionPriority   = 60;
        newAction.distanceToTarget = 1f;
        Owner.ScheduleNewAction(newAction);
        UseSmartObjectAction newSOAction = Owner.gameObject.AddComponent <UseSmartObjectAction>();

        newSOAction.targetBehaviour = smartObjectBehaviour;
        newSOAction.actionPriority  = 50;
        Owner.ScheduleNewAction(newSOAction);
    }
Beispiel #5
0
    public override void ApplyBehaviour()
    {
        target = GameObject.FindGameObjectWithTag("Player").transform;
        GoToAction newAction = Owner.gameObject.AddComponent <GoToAction>();

        newAction.target           = target;
        newAction.actionPriority   = 100;
        newAction.distanceToTarget = 0.8f;
        newAction.speedMultiplier  = 2f;
        Owner.ScheduleNewAction(newAction);
        KillPlayerAction newIdleAction = Owner.gameObject.AddComponent <KillPlayerAction>();

        Owner.ScheduleNewAction(newIdleAction);
    }
Beispiel #6
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // instantiate new Document object
            Document doc = new Document(dataDir + "Zoomed_pdf.pdf");

            // create GoToAction object
            GoToAction action = doc.OpenAction as GoToAction;

            // get the Zoom factor of PDF file
            System.Console.WriteLine((action.Destination as XYZExplicitDestination).Zoom); // Document zoom value;
        }
Beispiel #7
0
        private void CreateAction(RadFixedPage firstPage, Location location)
        {
            #region radpdfprocessing-model-annotations-and-destinations_3
            GoToAction goToAction = new GoToAction();
            goToAction.Destination = location;

            var goToLink = firstPage.Annotations.AddLink(goToAction);
            goToLink.Rect = new Rect(10, 10, 50, 50);

            UriAction uriAction = new UriAction();
            uriAction.Uri = new Uri(@"http://www.telerik.com");

            var uriLink = firstPage.Annotations.AddLink(uriAction);
            uriLink.Rect = new Rect(70, 10, 50, 50);
            #endregion
        }
        public static void Run()
        {
            // ExStart:SetZoomFactor
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments();

            // Instantiate new Document object
            Document doc = new Document(dataDir + "SetZoomFactor.pdf");

            GoToAction action = new GoToAction(new XYZExplicitDestination(1, 0, 0, .5));
            doc.OpenAction = action;
            dataDir = dataDir + "Zoomed_pdf_out.pdf";
            // Save the document
            doc.Save(dataDir);
            // ExEnd:SetZoomFactor
            Console.WriteLine("\nZoom factor setup successfully.\nFile saved at " + dataDir);
        }
Beispiel #9
0
    public override void ApplyBehaviour()
    {
        GoToAction newAction = Owner.gameObject.AddComponent <GoToAction>();

        newAction.target           = target;
        newAction.actionPriority   = 50;
        newAction.distanceToTarget = 2f;
        Owner.ScheduleNewAction(newAction);
        KillAgentAction newKillAction = Owner.gameObject.AddComponent <KillAgentAction>();

        newKillAction.target         = target;
        newKillAction.actionPriority = 50;
        Owner.ScheduleNewAction(newKillAction);
        GoToIdleAction newGTIAction = Owner.gameObject.AddComponent <GoToIdleAction>();

        newGTIAction.actionPriority = 50;
        Owner.ScheduleNewAction(newGTIAction);
    }
Beispiel #10
0
        public static void Run()
        {
            // ExStart:SetZoomFactor
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments();

            // Instantiate new Document object
            Document doc = new Document(dataDir + "SetZoomFactor.pdf");

            GoToAction action = new GoToAction(new XYZExplicitDestination(1, 0, 0, .5));

            doc.OpenAction = action;
            dataDir        = dataDir + "Zoomed_pdf_out.pdf";
            // Save the document
            doc.Save(dataDir);
            // ExEnd:SetZoomFactor
            Console.WriteLine("\nZoom factor setup successfully.\nFile saved at " + dataDir);
        }
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // Load the PDF file
            Document doc = new Document(dataDir + "input.pdf");
            // Get the first link annotation from first page of document
            LinkAnnotation linkAnnot = (LinkAnnotation)doc.Pages[1].Annotations[1];
            // Modification link: change link destination
            GoToAction goToAction = (GoToAction)linkAnnot.Action;

            // Specify the destination for link object
            // The first parameter is document object, second is destination page number.
            // The 5ht argument is zoom factor when displaying the respective page. When using 2, the page will be displayed in 200% zoom
            goToAction.Destination = new Aspose.Pdf.InteractiveFeatures.XYZExplicitDestination(doc, 1, 1, 2, 2);
            // Save the document with updated link
            doc.Save(dataDir + "PDFLINK_Modified_output.pdf");
        }
Beispiel #12
0
        private void loadOnOpenAction()
        {
            IPDFObject openAction = _dictionary["OpenAction"] as PDFDictionary;

            if (openAction is PDFDictionary)
            {
                PDFDictionary onOpen = openAction as PDFDictionary;
                if (onOpen != null)
                {
                    _onOpenAction = Action.Create(onOpen, _documentEssential);
                }
            }
            else if (openAction is PDFArray)
            {
                Destination dest   = new Destination(openAction, _documentEssential);
                GoToAction  action = new GoToAction(dest);
                action.Owner  = _documentEssential;
                _onOpenAction = action;
                _dictionary.AddItem("OpenAction", _onOpenAction.GetDictionary());
            }
        }
        public static void GoToAction()
        {
            Document document = new Document();
            Page     page1    = new Page();

            document.Pages.Add(page1);
            Page page2 = new Page();

            page2.Elements.Add(new Label("Page 2", 0, 0, 100, 15));
            document.Pages.Add(page2);

            Button button = new Button("btn", 50, 150, 100, 30);

            button.Label = "Click Here";
            GoToAction action = new GoToAction(2, PageZoom.FitWidth);

            button.ReaderEvents.MouseUp = action;

            page1.Elements.Add(button);
            document.Draw(Util.GetPath("Output/GoToAction.pdf"));
        }
        public static void Run()
        {
            // ExStart:SpecifyPageWhenViewing
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_LinksActions();

            // Load the PDF file
            Document doc = new Document(dataDir + "SpecifyPageWhenViewing.pdf");
            // Get the instance of second page of document
            Page page2 = doc.Pages[2];
            // Create the variable to set the zoom factor of target page
            double zoom = 1;
            // Create GoToAction instance
            GoToAction action = new GoToAction(doc.Pages[2]);
            // Go to 2 page
            action.Destination = new XYZExplicitDestination(page2, 0, page2.Rect.Height, zoom);
            // Set the document open action
            doc.OpenAction = action;
            // Save updated document
            doc.Save(dataDir + "goto2page_out.pdf");
            // ExEnd:SpecifyPageWhenViewing                        
        }
Beispiel #15
0
    public override void ApplyBehaviour()
    {
        if (Vector3.Distance(Owner.transform.position, target.position) < 0.4f)
        {
            return;
        }
        GoToAction newAction = Owner.gameObject.AddComponent <GoToAction>();

        newAction.target           = target;
        newAction.actionPriority   = 20;
        newAction.distanceToTarget = 0.4f;
        Owner.ScheduleNewAction(newAction);
        RotateToAction rotateAction = Owner.gameObject.AddComponent <RotateToAction>();

        rotateAction.target         = -target.rotation.eulerAngles;
        rotateAction.actionPriority = 10;
        Owner.ScheduleNewAction(rotateAction);
        GoToIdleAction newIdleAction = Owner.gameObject.AddComponent <GoToIdleAction>();

        newIdleAction.actionPriority = 0;
        Owner.ScheduleNewAction(newIdleAction);
    }
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // instantiate new Document object
            Document doc = new Document(dataDir + "input.pdf");

            //Set Left Right and Z factors
            double[] parameters = { 0, 0, 10 };

            //Set Explicit Destination
            ExplicitDestination ED = ExplicitDestination.CreateDestination(1, ExplicitDestinationType.XYZ, parameters);

            //Set Action
            GoToAction action = new GoToAction(ED);

            //Set Open action of document
            doc.OpenAction = action;

            //Save the document
            doc.Save(dataDir + "Zoomed_pdf.pdf");
        }
        internal override Action Clone(IDocumentEssential owner)
        {
            PDFDictionary dict = new PDFDictionary();

            dict.AddItem("Type", new PDFName("Action"));
            dict.AddItem("S", new PDFName("GoTo"));

            GoToAction action = new GoToAction(dict, owner);

            action.Destination = Destination;

            IPDFObject next = _dictionary["Next"];

            if (next != null)
            {
                for (int i = 0; i < Next.Count; ++i)
                {
                    action.Next.Add(Next[i]);
                }
            }

            return(action);
        }
Beispiel #18
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments();

            // instantiate new Document object
            Document doc = new Document(dataDir + "SetZoomFactor.pdf");

            //Set Left Right and Z factors
            double[] parameters = { 0, 0, 10 };

            //Set Explicit Destination
            ExplicitDestination ED = ExplicitDestination.CreateDestination(1, ExplicitDestinationType.XYZ, parameters);

            //Set Action
            GoToAction action = new GoToAction(ED);

            //Set Open action of document
            doc.OpenAction = action;

            //Save the document
            doc.Save(dataDir + "Zoomed_pdf.pdf");
        }
Beispiel #19
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments();

            // instantiate new Document object
            Document doc = new Document(dataDir + "SetZoomFactor.pdf");

            //Set Left Right and Z factors
            double[] parameters = {0,0,10};

            //Set Explicit Destination
            ExplicitDestination ED = ExplicitDestination.CreateDestination(1,ExplicitDestinationType.XYZ,parameters);

            //Set Action 
            GoToAction action = new GoToAction(ED);
            
            //Set Open action of document
            doc.OpenAction = action;

            //Save the document
            doc.Save(dataDir + "Zoomed_pdf.pdf");
        }
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // instantiate new Document object
            Document doc = new Document(dataDir + "input.pdf");

            //Set Left Right and Z factors
            double[] parameters = {0,0,10};

            //Set Explicit Destination
            ExplicitDestination ED = ExplicitDestination.CreateDestination(1,ExplicitDestinationType.XYZ,parameters);

            //Set Action
            GoToAction action = new GoToAction(ED);

            //Set Open action of document
            doc.OpenAction = action;

            //Save the document
            doc.Save(dataDir + "Zoomed_pdf.pdf");
        }
        public static void Run()
        {
            // ExStart:SpecifyPageWhenViewing
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_LinksActions();

            // Load the PDF file
            Document doc = new Document(dataDir + "SpecifyPageWhenViewing.pdf");
            // Get the instance of second page of document
            Page page2 = doc.Pages[2];
            // Create the variable to set the zoom factor of target page
            double zoom = 1;
            // Create GoToAction instance
            GoToAction action = new GoToAction(doc.Pages[2]);

            // Go to 2 page
            action.Destination = new XYZExplicitDestination(page2, 0, page2.Rect.Height, zoom);
            // Set the document open action
            doc.OpenAction = action;
            // Save updated document
            doc.Save(dataDir + "goto2page_out_.pdf");
            // ExEnd:SpecifyPageWhenViewing
        }
Beispiel #22
0
        public static void AddLinkInsideDocument()
        {
            PdfFile     pdfFile  = new PdfFile();
            PdfDocument document = pdfFile.Import(File.ReadAllBytes("sample.pdf"));

            PdfPage            page    = document.Pages[0];
            PageContentBuilder builder = new PageContentBuilder(page);

            builder.GraphicState.FillColor = new RgbColor(100, 255, 0, 0);

            //Add internal link with Destination
            PageFit pageFit = document.Destinations.AddPageFit();

            //Navigate to the second page
            pageFit.Page = document.Pages[1];
            Rect rectArea            = new Rect(50, 100, 100, 100);
            Link linkWithDestination = new Link(pageFit);

            linkWithDestination.Rect = rectArea;
            page.Annotations.Add(linkWithDestination);
            builder.DrawRectangle(rectArea);

            //Add internal link with Location
            Location location = new Location();

            //Navigate to second page
            location.Page = document.Pages[1];
            //Navigate to the target point in page
            location.Left = 275;
            location.Top  = 400;
            //Set Zoom value in viewer, the value "3" means showing in 300% of original size
            location.Zoom = 3;
            rectArea      = new Rect(50, 250, 100, 100);
            Link linkWithLocation = page.Annotations.AddLink(location);

            linkWithLocation.Rect = rectArea;
            builder.DrawRectangle(rectArea);

            //Add internal link with Action
            GoToAction goToAction = new GoToAction();

            //Set navigation to either Destination or Location
            goToAction.Destination = location;
            //goToAction.Destination = pageFit;
            rectArea = new Rect(50, 400, 100, 100);
            Link goToLink = page.Annotations.AddLink(goToAction);

            goToLink.Rect = rectArea;
            builder.DrawRectangle(rectArea);

            //Add internal link with Block
            Block block = new Block();

            block.InsertText("This is a ");
            block.GraphicState.FillColor = new RgbColor(0, 0, 255);
            //Set navigation to either Destination or Location
            block.InsertHyperlinkStart(pageFit);
            //block.InsertHyperlinkStart(location);
            block.InsertText("navigation link");
            block.InsertHyperlinkEnd();
            builder.Position.Translate(50, 550);
            builder.DrawBlock(block);

            File.WriteAllBytes("AddLink.pdf", pdfFile.Export(document));
        }
        /**
         * Mouse up handler.
         * All annotation transformation is performed in mouse move handler.
         * This handler is for context menu calls, and for finishing annotation tracking.
         */
        public override void MouseUp(MouseEventArgs e, System.Drawing.Point location)
        {
            captured = false;
            if (!docView.EditPermission)
            {
                return;
            }

            if (e.Button == MouseButtons.Right)
            {
                if (docView.ActiveAnnotation != null)
                {
                    ContextMenu currentContextMenu = null;

                    switch (docView.ActiveAnnotation.Properties.Subtype)
                    {
                    case "FreeText":
                        currentContextMenu = textAnnotationContextMenu;
                        break;

                    case "Link":
                        currentContextMenu = linkAnnotationContextMenu;
                        break;

                    default:
                        currentContextMenu = shapeAnnotationContextMenu;
                        break;
                    }
                    if (currentContextMenu != null)
                    {
                        UpdateMenuItems(currentContextMenu);
                        currentContextMenu.Show(docView.Parent, e.Location);
                    }
                }
            }
            else
            {
                docView.EditCheckPoint();
                if (e.Button == MouseButtons.Left && Control.ModifierKeys == Keys.Control && (docView.ActiveAnnotation != null || cachedIndex != -1))
                {
                    BaseAnnotationEditor editor = docView.EditAnnotations[cachedIndex];
                    if (editor is LinkAnnotationEditor)
                    {
                        LinkAnnotation annot = editor.Annotation as LinkAnnotation;
                        if (annot.Action is URIAction)
                        {
                            URIAction act = annot.Action as URIAction;
                            System.Diagnostics.Process.Start(act.URI);
                        }
                        else if (annot.Action is RemoteGoToAction)
                        {
                            RemoteGoToAction  action = annot.Action as RemoteGoToAction;
                            FileSpecification spec   = action.FileSpecification;

                            string fullPath = System.IO.Path.GetFullPath(spec.Path);
                            if (System.IO.File.Exists(fullPath))
                            {
                                System.Diagnostics.Process.Start(fullPath);
                            }
                        }
                        else if (annot.Action is GoToAction || annot.Destination != null)
                        {
                            GoToAction      action = (annot.Action as GoToAction);
                            ViewDestination dest   = action == null ? annot.Destination : action.Destination;

                            if (dest != null)
                            {
                                docView.GoToDestionation(dest);
                            }
                        }
                    }
                }
            }
        }
 public ActionData(GoToAction action) : this(action.Destination)
 {
 }
Beispiel #25
0
        static void Main(string[] args)
        {
            Console.WriteLine("Actions Sample:");

            using (Library lib = new Library())
            {
                String sOutput = "../Actions-out.pdf";

                Console.WriteLine("Initialized the library.");

                Document doc = new Document();

                using (Path newpath = new Path())
                {
                    // Create a PDF page which is the same size of the image.
                    Rect pageRect = new Rect(0, 0, 100, 100);
                    Page docpage  = doc.CreatePage(Document.BeforeFirstPage,
                                                   pageRect);
                    Console.WriteLine("Created page.");

                    // Create our first link with a URI action
                    LinkAnnotation newLink = (LinkAnnotation)docpage.CreateAnnotation("Link", new Rect(1.0, 2.0, 3.0, 4.0));
                    Console.WriteLine(newLink.ToString());

                    doc.BaseURI = "http://www.datalogics.com";
                    URIAction uri = new URIAction("/products/pdfl/pdflibrary.asp", false);
                    Console.WriteLine("Action data: " + uri.ToString());

                    newLink.Action = uri;
                    docpage.AddAnnotation(-2, newLink);

                    // Create a second link with a GoTo action
                    LinkAnnotation secondLink = (LinkAnnotation)docpage.CreateAnnotation("Link", new Rect(5.0, 6.0, 7.0, 8.0));

                    Rect       r   = new Rect(5, 5, 100, 100);
                    GoToAction gta = new GoToAction(new ViewDestination(doc, 0, "FitR", r, 1.0));
                    Console.WriteLine("Action data: " + gta.ToString());

                    secondLink.Action = gta;
                    docpage.AddAnnotation(-2, secondLink);

                    // Read some URI properties
                    Console.WriteLine("Extracted URI: " + uri.URI);

                    if (uri.IsMap)
                    {
                        Console.WriteLine("Send mouse coordinates");
                    }
                    else
                    {
                        Console.WriteLine("Don't send mouse coordinates");
                    }

                    // Change the URI properties
                    doc.BaseURI = "http://www.datalogics.com";
                    uri.URI     = "/products/pdfl/pdflibrary.asp";

                    uri.IsMap = true;

                    Console.WriteLine("Complete changed URI:" + doc.BaseURI + uri.URI);

                    if (uri.IsMap)
                    {
                        Console.WriteLine("Send mouse coordinates");
                    }
                    else
                    {
                        Console.WriteLine("Don't send mouse coordinates");
                    }

                    // Testing gta
                    Console.WriteLine("Fit type of destination: " + gta.Destination.FitType.ToString());
                    Console.WriteLine("Rectangle of destination: " + gta.Destination.DestRect.ToString());
                    Console.WriteLine("Zoom of destination: " + gta.Destination.Zoom.ToString());
                    Console.WriteLine("Page number of destination: " + gta.Destination.PageNumber.ToString());

                    doc.Save(SaveFlags.Full, sOutput);
                }
            }
        }