Example #1
0
        public static PdfAnnotation ConvertAnnotation(PdfWriter writer, Annotation annot, Rectangle defaultRect)
        {
            switch (annot.AnnotationType)
            {
            case Annotation.URL_NET:
                return(new PdfAnnotation(writer, annot.GetLlx(), annot.GetLly(), annot.GetUrx(), annot.GetUry(), new PdfAction((Uri)annot.Attributes[Annotation.URL])));

            case Annotation.URL_AS_STRING:
                return(new PdfAnnotation(writer, annot.GetLlx(), annot.GetLly(), annot.GetUrx(), annot.GetUry(), new PdfAction((String)annot.Attributes[Annotation.FILE])));

            case Annotation.FILE_DEST:
                return(new PdfAnnotation(writer, annot.GetLlx(), annot.GetLly(), annot.GetUrx(), annot.GetUry(), new PdfAction((String)annot.Attributes[Annotation.FILE], (String)annot.Attributes[Annotation.DESTINATION])));

            case Annotation.SCREEN:
                bool[] sparams  = (bool[])annot.Attributes[Annotation.PARAMETERS];
                String fname    = (String)annot.Attributes[Annotation.FILE];
                String mimetype = (String)annot.Attributes[Annotation.MIMETYPE];
                PdfFileSpecification fs;
                if (sparams[0])
                {
                    fs = PdfFileSpecification.FileEmbedded(writer, fname, fname, null);
                }
                else
                {
                    fs = PdfFileSpecification.FileExtern(writer, fname);
                }
                PdfAnnotation ann = PdfAnnotation.CreateScreen(writer, new Rectangle(annot.GetLlx(), annot.GetLly(), annot.GetUrx(), annot.GetUry()),
                                                               fname, fs, mimetype, sparams[1]);
                return(ann);

            case Annotation.FILE_PAGE:
                return(new PdfAnnotation(writer, annot.GetLlx(), annot.GetLly(), annot.GetUrx(), annot.GetUry(), new PdfAction((String)annot.Attributes[Annotation.FILE], (int)annot.Attributes[Annotation.PAGE])));

            case Annotation.NAMED_DEST:
                return(new PdfAnnotation(writer, annot.GetLlx(), annot.GetLly(), annot.GetUrx(), annot.GetUry(), new PdfAction((int)annot.Attributes[Annotation.NAMED])));

            case Annotation.LAUNCH:
                return(new PdfAnnotation(writer, annot.GetLlx(), annot.GetLly(), annot.GetUrx(), annot.GetUry(), new PdfAction((String)annot.Attributes[Annotation.APPLICATION], (String)annot.Attributes[Annotation.PARAMETERS], (String)annot.Attributes[Annotation.OPERATION], (String)annot.Attributes[Annotation.DEFAULTDIR])));

            default:
                return(new PdfAnnotation(writer, defaultRect.Left, defaultRect.Bottom, defaultRect.Right, defaultRect.Top, new PdfString(annot.Title, PdfObject.TEXT_UNICODE), new PdfString(annot.Content, PdfObject.TEXT_UNICODE)));
            }
        }