public static PdfAnnotation ToPDFLine(this Autodesk.DesignScript.Geometry.Line line, string content, PdfWriter writer)
        {
            var start = line.StartPoint.ToPDFCoords();
            var end   = line.EndPoint.ToPDFCoords();

            iTextSharp.text.Rectangle rect = new iTextSharp.text.Rectangle(start.X, start.Y);

            var app  = new PdfContentByte(writer);
            var anno = PdfAnnotation.CreateLine(writer, rect, content, start.X, start.Y, end.X, end.Y);

            return(anno);
        }
Exemplo n.º 2
0
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
        public static PdfAnnotation ToPDFLine(this Autodesk.DesignScript.Geometry.Line line, string content, PdfWriter writer)
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
        {
            var start = line.StartPoint.ToPDFCoords();
            var end   = line.EndPoint.ToPDFCoords();

            iTextSharp.text.Rectangle rect = new iTextSharp.text.Rectangle(start.X, start.Y);

            var app  = new PdfContentByte(writer);
            var anno = PdfAnnotation.CreateLine(writer, rect, content, start.X, start.Y, end.X, end.Y);

            return(anno);
        }
Exemplo n.º 3
0
// ---------------------------------------------------------------------------

        /**
         * Manipulates a PDF file src with the file dest as result
         * @param src the original PDF
         */
        public override byte[] ManipulatePdf(byte[] src)
        {
            locations = PojoFactory.GetLocations();
            // Create a reader
            PdfReader reader = new PdfReader(src);

            using (MemoryStream ms = new MemoryStream()) {
                // Create a stamper
                using (PdfStamper stamper = new PdfStamper(reader, ms)) {
                    // Loop over the days and screenings
                    int           page = 1;
                    Rectangle     rect;
                    float         top;
                    PdfAnnotation annotation;
                    Movie         movie;
                    foreach (string day in PojoFactory.GetDays())
                    {
                        foreach (Screening screening in PojoFactory.GetScreenings(day))
                        {
                            rect  = GetPosition(screening);
                            movie = screening.movie;
                            // Annotation for press previews
                            if (screening.Press)
                            {
                                annotation = PdfAnnotation.CreateStamp(
                                    stamper.Writer, rect, "Press only", "NotForPublicRelease"
                                    );
                                annotation.Color = BaseColor.BLACK;
                                annotation.Flags = PdfAnnotation.FLAGS_PRINT;
                            }
                            // Annotation for screenings that are sold out
                            else if (IsSoldOut(screening))
                            {
                                top        = reader.GetPageSizeWithRotation(page).Top;
                                annotation = PdfAnnotation.CreateLine(
                                    stamper.Writer, rect, "SOLD OUT",
                                    top - rect.Top, rect.Right,
                                    top - rect.Bottom, rect.Left
                                    );
                                annotation.Title       = movie.MovieTitle;
                                annotation.Color       = BaseColor.WHITE;
                                annotation.Flags       = PdfAnnotation.FLAGS_PRINT;
                                annotation.BorderStyle = new PdfBorderDictionary(
                                    5, PdfBorderDictionary.STYLE_SOLID
                                    );
                            }
                            // Annotation for screenings with tickets available
                            else
                            {
                                annotation = PdfAnnotation.CreateSquareCircle(
                                    stamper.Writer, rect, "Tickets available", true
                                    );
                                annotation.Title  = movie.MovieTitle;
                                annotation.Color  = BaseColor.BLUE;
                                annotation.Flags  = PdfAnnotation.FLAGS_PRINT;
                                annotation.Border = new PdfBorderArray(
                                    0, 0, 2, new PdfDashPattern()
                                    );
                            }
                            stamper.AddAnnotation(annotation, page);
                        }
                        page++;
                    }
                }
                return(ms.ToArray());
            }
        }