public static void Run()
        {
            // ExStart:AddSwfFileAsAnnotation
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

            // Open the PDF document
            Document doc = new Document(dataDir + "AddSwfFileAsAnnotation.pdf");
            
            // Get reference of the page to which you need to add the annotation
            Page page = doc.Pages[1];
            
            // Create ScreenAnnotation object with .swf multimedia file as an argument
            ScreenAnnotation annotation = new ScreenAnnotation(page, new Aspose.Pdf.Rectangle(0, 400, 600, 700), dataDir + "input.swf");
           
            // Add the annotation to annotations collection of page
            page.Annotations.Add(annotation);

            dataDir = dataDir + "AddSwfFileAsAnnotation_out.pdf";
            // Save the update PDF document with annotation
            doc.Save(dataDir);
            // ExEnd:AddSwfFileAsAnnotation
            Console.WriteLine("\nSWF file annotation added to pdf document.\nFile saved at " + dataDir);

        }
Beispiel #2
0
        internal override Annotation Clone(IDocumentEssential owner, Page page)
        {
            if (Page == null)
            {
                ApplyOwner(owner);
                SetPage(page, true);
                return(this);
            }

            PDFDictionary res = AnnotationBase.Copy(Dictionary);

            IPDFObject t = Dictionary["T"];

            if (t != null)
            {
                res.AddItem("T", t.Clone());
            }

            PDFDictionary mk = Dictionary["MK"] as PDFDictionary;

            if (mk != null)
            {
                res.AddItem("MK", AppearanceCharacteristics.Copy(mk));
            }

            ScreenAnnotation annot = new ScreenAnnotation(res, owner);

            annot.SetPage(Page, false);
            annot.SetPage(page, true);

            annot.OnActivated     = OnActivated;
            annot.OnMouseDown     = OnMouseDown;
            annot.OnMouseEnter    = OnMouseEnter;
            annot.OnMouseExit     = OnMouseExit;
            annot.OnMouseUp       = OnMouseUp;
            annot.OnPageClose     = OnPageClose;
            annot.OnPageInvisible = OnPageInvisible;
            annot.OnPageOpen      = OnPageOpen;
            annot.OnPageVisible   = OnPageVisible;

            return(annot);
        }
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            //Open the PDF document
            Document doc = new Document(dataDir + "input.pdf");

            // get reference of the page to which you need to add the annotation
            Page page = doc.Pages[1];

            // create ScreenAnnotation object with .swf multimedia file as an argument
            ScreenAnnotation annotation = new ScreenAnnotation(page, new Aspose.Pdf.Rectangle(0, 400, 600, 700), dataDir + "input.swf");

            // add the annotation to annotations collection of page
            page.Annotations.Add(annotation);

            // save the update PDF document with annotation
            doc.Save(dataDir + "output.pdf");
        }
Beispiel #4
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

            //Open the PDF document
            Document doc = new Document(dataDir + "AddSwfFileAsAnnotation.pdf");

            // get reference of the page to which you need to add the annotation
            Page page = doc.Pages[1];

            // create ScreenAnnotation object with .swf multimedia file as an argument
            ScreenAnnotation annotation = new ScreenAnnotation(page, new Aspose.Pdf.Rectangle(0, 400, 600, 700), dataDir + "input.swf");

            // add the annotation to annotations collection of page
            page.Annotations.Add(annotation);

            // save the update PDF document with annotation
            doc.Save(dataDir + "AddSwfFileAsAnnotation_out.pdf");
        }
Beispiel #5
0
        public static void Run()
        {
            // ExStart:GetResourceOfAnnotation
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

            // Open document
            Document doc = new Document(dataDir + "AddAnnotation.pdf");
            //Create annotation
            ScreenAnnotation sa = new ScreenAnnotation(doc.Pages[1], new Rectangle(100, 400, 300, 600), dataDir + "AddSwfFileAsAnnotation.swf");

            doc.Pages[1].Annotations.Add(sa);
            // Save Doucument
            doc.Save(dataDir + "GetResourceOfAnnotation_Out.pdf");
            // Open document
            Document doc1 = new Document(dataDir + "GetResourceOfAnnotation_Out.pdf");
            //Get action of the annotation
            RenditionAction action = (doc.Pages[1].Annotations[1] as ScreenAnnotation).Action as RenditionAction;
            //Get rendition of the rendition action
            Rendition rendition = ((doc.Pages[1].Annotations[1] as ScreenAnnotation).Action as RenditionAction).Rendition;
            //Media Clip
            MediaClip         clip = (rendition as MediaRendition).MediaClip;
            FileSpecification data = (clip as MediaClipData).Data;
            MemoryStream      ms   = new MemoryStream();

            byte[] buffer = new byte[1024];
            int    read   = 0;
            //Data of media are accessible in FileSpecification.Contents
            Stream source = data.Contents;

            while ((read = source.Read(buffer, 0, buffer.Length)) > 0)
            {
                ms.Write(buffer, 0, read);
            }
            Console.WriteLine(rendition.Name);
            Console.WriteLine(action.RenditionOperation);
            // ExStart:GetResourceOfAnnotation
        }
        public void PutScreenAnnotationTest()
        {
            UploadFile(NameSwf, NameSwf);
            ScreenAnnotation annotation = new ScreenAnnotation(Rect: new Rectangle(100, 100, 200, 200))
            {
                Name  = "Updated Test",
                Flags = new List <AnnotationFlags> {
                    AnnotationFlags.Hidden, AnnotationFlags.NoView
                },
                HorizontalAlignment = HorizontalAlignment.Center,
                ZIndex   = 1,
                Title    = "Title Updated",
                Modified = "01/01/2018 00:00:00.000 AM",
                FilePath = Path.Combine(TempFolder, NameSwf),
            };

            var    lineResponse = PdfApi.GetDocumentScreenAnnotations(Name, folder: TempFolder);
            string annotationId = lineResponse.Annotations.List[0].Id;

            var response = PdfApi.PutScreenAnnotation(Name, annotationId, annotation, folder: TempFolder);

            Assert.That(response.Code, Is.EqualTo(200));
        }
Beispiel #7
0
        public static void Run()
        {
            // ExStart:AddSwfFileAsAnnotation
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

            // Open the PDF document
            Document doc = new Document(dataDir + "AddSwfFileAsAnnotation.pdf");

            // Get reference of the page to which you need to add the annotation
            Page page = doc.Pages[1];

            // Create ScreenAnnotation object with .swf multimedia file as an argument
            ScreenAnnotation annotation = new ScreenAnnotation(page, new Aspose.Pdf.Rectangle(0, 400, 600, 700), dataDir + "input.swf");

            // Add the annotation to annotations collection of page
            page.Annotations.Add(annotation);

            dataDir = dataDir + "AddSwfFileAsAnnotation_out_.pdf";
            // Save the update PDF document with annotation
            doc.Save(dataDir);
            // ExEnd:AddSwfFileAsAnnotation
            Console.WriteLine("\nSWF file annotation added to pdf document.\nFile saved at " + dataDir);
        }
Beispiel #8
0
        private void parseAnnotations()
        {
            for (int i = 0; i < _array.Count; ++i)
            {
                PDFDictionary annotDict = _array[i] as PDFDictionary;
                if (annotDict != null)
                {
                    if (annotDict["IRT"] == null)
                    {
                        PDFName subtype = annotDict["Subtype"] as PDFName;
                        if (subtype != null)
                        {
                            Annotation annot = null;
                            switch (subtype.GetValue())
                            {
                            case "Text":
                                annot = new TextAnnotation(annotDict, _owner);
                                break;

                            case "Link":
                                annot = new LinkAnnotation(annotDict, _owner);
                                break;

                            case "FreeText":
                                annot = new FreeTextAnnotation(annotDict, _owner);
                                break;

                            case "Line":
                                annot = new LineAnnotation(annotDict, _owner);
                                break;

                            case "Square":
                                annot = new SquareAnnotation(annotDict, _owner);
                                break;

                            case "Circle":
                                annot = new CircleAnnotation(annotDict, _owner);
                                break;

                            case "Polygon":
                                annot = new PolygonAnnotation(annotDict, _owner);
                                break;

                            case "PolyLine":
                                annot = new PolylineAnnotation(annotDict, _owner);
                                break;

                            case "Highlight":
                                annot = new HighlightAnnotation(annotDict, _owner);
                                break;

                            case "Underline":
                                annot = new UnderlineAnnotation(annotDict, _owner);
                                break;

                            case "Squiggly":
                                annot = new SquigglyAnnotation(annotDict, _owner);
                                break;

                            case "StrikeOut":
                                annot = new StrikeOutAnnotation(annotDict, _owner);
                                break;

                            case "Stamp":
                                annot = new RubberStampAnnotation(annotDict, _owner);
                                break;

                            case "Caret":
                                annot = new CaretAnnotation(annotDict, _owner);
                                break;

                            case "Ink":
                                annot = new InkAnnotation(annotDict, _owner);
                                break;

                            case "FileAttachment":
                                annot = new FileAttachmentAnnotation(annotDict, _owner);
                                break;

                            case "Sound":
                                annot = new SoundAnnotation(annotDict, _owner);
                                break;

                            case "Movie":
                                annot = new MovieAnnotation(annotDict, _owner);
                                break;

                            case "Screen":
                                annot = new ScreenAnnotation(annotDict, _owner);
                                break;

                            case "3D":
                                annot = new ThreeDAnnotation(annotDict, _owner);
                                break;

                            case "Widget":
                                PDFName ft = annotDict["FT"] as PDFName;
                                if (ft == null)
                                {
                                    PDFDictionary parent = annotDict["Parent"] as PDFDictionary;
                                    if (parent != null)
                                    {
                                        ft = parent["FT"] as PDFName;
                                    }
                                }

                                if (ft != null)
                                {
                                    switch (ft.GetValue())
                                    {
                                    case "Tx":
                                        annot = new EditBox(annotDict, _owner);
                                        break;

                                    case "Ch":
                                        uint flag = getFlag(annotDict);
                                        if ((flag >> 17) % 2 != 0)
                                        {
                                            annot = new ComboBox(annotDict, _owner);
                                        }
                                        else
                                        {
                                            annot = new ListBox(annotDict, _owner);
                                        }
                                        break;

                                    case "Btn":
                                        flag = getFlag(annotDict);
                                        if ((flag >> 16) % 2 != 0)
                                        {
                                            annot = new PushButton(annotDict, _owner);
                                        }
                                        else if ((flag >> 15) % 2 != 0)
                                        {
                                            annot = new RadioButton(annotDict, _owner);
                                        }
                                        else
                                        {
                                            annot = new CheckBox(annotDict, _owner);
                                        }
                                        break;
                                    }
                                }
                                break;
                            }

                            if (annot != null)
                            {
                                annot.SetPage(_page, false);
                                _annotations.Add(annot);
                            }
                        }
                    }
                }
            }
        }