GetVerticalPosition() public méthode

public GetVerticalPosition ( bool ensureNewLine ) : float
ensureNewLine bool
Résultat float
 public override void OnEndPage(PdfWriter writer, Document document) {
     Rectangle pageSize = writer.PageSize;
     float verticalPosition = writer.GetVerticalPosition(false);
     PdfContentByte canvas = writer.DirectContent;
     Rectangle rect = new Rectangle(0, verticalPosition, pageSize.Right, pageSize.Top);
     rect.Border = Rectangle.BOX;
     rect.BorderWidth = 1;
     rect.BorderColor = BaseColor.BLUE;
     canvas.Rectangle(rect);
 }
        public int ResultSheets(Document doc, int ShowID, int RingID, int Position , bool pagePerClass, PdfWriter writer )
        {
            int ret = 0;
            Font smallFont = new Font(Font.COURIER, 8, Font.NORMAL, Color.BLACK);
            Font normalFont = new Font(Font.COURIER, 10, Font.NORMAL, Color.BLACK);
            Font bigFont = new Font(Font.HELVETICA, 25, Font.NORMAL, Color.BLACK);
            Font mediumFont = new Font(Font.HELVETICA, 20, Font.NORMAL, Color.BLACK);
            ShowClasses sc = new ShowClasses();
            Rings currentRing = new Rings(RingID);
            List<ShowClasses> showClasses = ShowClasses.GetAllClassesForShowRing(ShowID, RingID, Position);
            var storedResults = Business.TrophiesRosettes.getTandRForShow(ShowID);
            var lineLeft = writer.GetVerticalPosition(false) - doc.BottomMargin;

            ret = showClasses.Count;
            PdfPTable callingListTbl = null;
            foreach (ShowClasses showClass in showClasses)
            {
                var resultCnts = storedResults.Where(x => x.ClsNo == showClass.ClassNo);

                int gradeidx = 0;
                foreach (var totals in resultCnts)
                {
                    PdfPTable ptable = new PdfPTable(3);
                    PdfPCell cell;

                    String grades;
                    String subTitle;

                    if (_writer != null)
                    {
                        _writer.GetVerticalPosition(false);
                    }

                    if (showClass.Catagory == 0)
                    {
                        if (gradeidx < showClass.Grades.Length)
                        {
                            grades = "Grade " + showClass.Grades[gradeidx];
                        }
                        else
                        {
                            grades = showClass.Grades;
                        }
                        subTitle = String.Format("{0} {1} {2} {3} {5}{6} Judge: {4}", showClass.longHeight, showClass.longCatagory, showClass.LongClassName, grades, Judge.getJudgeForClass(showClass.ID).JudgeName, showClass.ClassName, (showClass.Part > 0 ? "Part " + showClass.Part : ""));
                    }
                    else
                    {
                        if (showClass.Grades.Length == 1)
                        {
                            grades = showClass.Grades;
                        }
                        else
                        {
                            grades = showClass.Grades[0] + " - " + showClass.Grades[showClass.Grades.Length - 1];
                        }
                        subTitle = String.Format("{0} {1} Judge: {2}", showClass.NormalName(withClassNo:false), (showClass.Part > 0 ? "Part " + showClass.Part : ""), Judge.getJudgeForClass(showClass.ID).JudgeName);

                    }
                    String tmp = String.Format("Ring No:{0} - Result Sheet ", currentRing.RingNo);
                    cell = new PdfPCell(new Phrase(new Chunk(tmp, bigFont)));
                    cell.Colspan = 2;
                    cell.BorderWidth = 0;
                    ptable.AddCell(cell);

                    tmp = String.Format("Class No:{0}", showClass.ClassNo);
                    cell = new PdfPCell(new Phrase(new Chunk(tmp, bigFont)));
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    cell.BorderWidth = 2;
                    cell.Padding = 5;
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase(new Chunk(subTitle, mediumFont)));
                    cell.Colspan = 3;
                    cell.BorderWidth = 0;
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase(new Chunk("", ClassTitleFont)));
                    cell.Colspan = 3;
                    cell.BorderWidth = 0;
                    ptable.AddCell(cell);
                    ptable.AddCell(cell);
                    ptable.AddCell(cell);
                    doc.Add(ptable);
                    DrawCourseBoxes(doc);

                    float[] colWidths = { 75, 75, 200, 200, 50, 75 };
                    callingListTbl = new PdfPTable(colWidths);

                    cell = new PdfPCell(new Phrase(new Chunk("Place", headerHFont)));
                    cell.BorderWidth = 1;
                    cell.BorderWidthBottom = 0;
                    cell.FixedHeight = 35f;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    callingListTbl.AddCell(cell);

                    if (TeamPairsManager.isMultiDog(showClass.EntryType))
                    {
                        if (TeamPairsManager.isTeam(showClass.EntryType))
                        {
                            cell = new PdfPCell(new Phrase(new Chunk("Team Name", headerHFont)));
                        }
                        else
                        {
                            cell = new PdfPCell(new Phrase(new Chunk("Handler/Dog", headerHFont)));
                        }
                        cell.BorderWidth = 1;
                        cell.BorderWidthBottom = 0;
                        cell.Colspan = 3;
                        callingListTbl.AddCell(cell);
                    } else
                    {
                        cell = new PdfPCell(new Phrase(new Chunk("Ring Number", headerHFont)));
                        cell.BorderWidth = 1;
                        cell.BorderWidthBottom = 0;
                        cell.HorizontalAlignment = Element.ALIGN_CENTER;
                        callingListTbl.AddCell(cell);

                        cell = new PdfPCell(new Phrase(new Chunk("Handler", headerHFont)));
                        cell.BorderWidth = 1;
                        cell.BorderWidthBottom = 0;
                        cell.HorizontalAlignment = Element.ALIGN_CENTER;
                        callingListTbl.AddCell(cell);

                        cell = new PdfPCell(new Phrase(new Chunk("Dog Name", headerHFont)));
                        cell.BorderWidth = 1;
                        cell.BorderWidthBottom = 0;
                        cell.HorizontalAlignment = Element.ALIGN_CENTER;
                        callingListTbl.AddCell(cell);

                    }

                    cell = new PdfPCell(new Phrase(new Chunk("Clear/ Faults", headerHFont)));
                    cell.BorderWidth = 1;
                    cell.BorderWidthBottom = 0;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    callingListTbl.AddCell(cell);

                    cell = new PdfPCell(new Phrase(new Chunk("Time", headerHFont)));
                    cell.BorderWidth = 1;
                    cell.BorderWidthBottom = 0;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    callingListTbl.AddCell(cell);

                    int maxRosettes = totals.Rosettes;// Utils.calcRosettes(dogCounts);
                    int maxTrophies = totals.Trophies; // Utils.calcTrophies(dogCounts);
                    float rowHeight = 25f;
                    if (TeamPairsManager.isMultiDog(showClass.EntryType)  )
                    {
                        rowHeight = (TeamPairsManager.isTeam(showClass.EntryType)) ? 120f : 65f;
                    }

                    for (int resultRow = 0; resultRow < maxRosettes; resultRow++)
                    {
                        int bwb = 0;
                        if (resultRow == maxRosettes - 1)
                        {
                            bwb = 1;
                        }
                        Color background = Color.WHITE;
                        if (maxTrophies > 0)
                        {
                            background = Color.LIGHT_GRAY;
                        }
                        maxTrophies--;
                        cell = new PdfPCell(new Phrase(new Chunk(calcPlace(resultRow + 1), normalFont)));
                        cell.BorderWidth = 1;
                        cell.BorderWidthBottom = bwb;
                        cell.FixedHeight = rowHeight;
                        cell.HorizontalAlignment = Element.ALIGN_CENTER;
                        cell.BackgroundColor = background;
                        callingListTbl.AddCell(cell);

                        if (TeamPairsManager.isMultiDog(showClass.EntryType))
                        {
                            cell = new PdfPCell(new Phrase(new Chunk("", normalFont)));
                            cell.BorderWidth = 1;
                            cell.BackgroundColor = background;
                            cell.BorderWidthBottom = bwb;
                            cell.Colspan = 3;
                            callingListTbl.AddCell(cell);
                            cell = new PdfPCell(new Phrase(new Chunk("", normalFont)));
                            cell.BorderWidth = 1;
                            cell.BackgroundColor = background;
                            cell.BorderWidthBottom = bwb;
                            callingListTbl.AddCell(cell);
                            callingListTbl.AddCell(cell);

                        }
                        else
                        {
                            cell = new PdfPCell(new Phrase(new Chunk("", normalFont)));
                            cell.BorderWidth = 1;
                            cell.BackgroundColor = background;
                            cell.BorderWidthBottom = bwb;

                            callingListTbl.AddCell(cell);
                            callingListTbl.AddCell(cell);
                            callingListTbl.AddCell(cell);
                            callingListTbl.AddCell(cell);
                            callingListTbl.AddCell(cell);
                        }

                    }
                    doc.Add(callingListTbl);

                    ptable = new PdfPTable(3);
                    cell = new PdfPCell(new Phrase(new Chunk("", ClassTitleFont)));
                    cell.Colspan = 3;
                    cell.BorderWidth = 0;
                    cell.FixedHeight = 60f;
                    ptable.AddCell(cell);
                    doc.Add(ptable);

                    lineLeft = writer.GetVerticalPosition(false) - doc.BottomMargin;
                    if (lineLeft < 200)
                    {
                        doc.NewPage();
                    }
                    //doc.NewPage();
                    gradeidx++;
                }
            }

            return ret;
        }
Exemple #3
0
 public override void Write(PdfWriter writer, Document doc) {
     PdfDestination destination = new PdfDestination(PdfDestination.XYZ, 20,
             writer.GetVerticalPosition(false), 0);
     IDictionary<String, Object> memory = context.GetMemory();
     HeaderNode tree = null;
     if (memory.ContainsKey(HtmlPipelineContext.BOOKMARK_TREE))
         tree = (HeaderNode)memory[HtmlPipelineContext.BOOKMARK_TREE];
     int level = header.GetLevel(tag);
     if (null == tree) {
         // first h tag encounter
         tree = new HeaderNode(0, writer.RootOutline, null);
     }
     else {
         // calculate parent
         int lastLevel = tree.Level;
         if (lastLevel == level) {
             tree = tree.Parent;
         }
         else if (lastLevel > level) {
             while (lastLevel >= level) {
                 lastLevel = tree.Parent.Level;
                 tree = tree.Parent;
             }
         }
     }
     if (LOGGER.IsLogging(Level.TRACE)) {
         LOGGER.Trace(String.Format(LocaleMessages.GetInstance().GetMessage(LocaleMessages.ADD_HEADER), title.ToString()));
     }
     HeaderNode node = new HeaderNode(level, new PdfOutline(tree.Outline, destination, title), tree);
     memory[HtmlPipelineContext.BOOKMARK_TREE] = node;
 }
        public int CallingSheets(Document doc, int showId, int ringId, PdfWriter writer, int position = -1)
        {
            doc.Open();
            var font = new Font(Font.COURIER, 10, Font.NORMAL, Color.BLACK);
            var fontBold = new Font(Font.COURIER, 10, Font.BOLD, Color.BLACK);
            var sc = new ShowClasses();
            var currentRing = new Rings(ringId);
            var showClasses = ShowClasses.GetAllClassesForShowRing(showId, ringId, position);
            var ret = showClasses.Count;
            float[] colWidthsStandard = { 35, 35, 50, 200, 200 };
            float[] colWidthsTeam = { 35, 200, 200 };
            PdfPTable callingListTbl = null;
            var currentClassNo = 0;
            var multiClasses = TeamPairsManager.GetTeamPairClasses(showId);
            var multiTeams = TeamPairsManager.GetTeamPairsForShow(showId, multiClasses);
            foreach (var showClass in showClasses)
            {
                var colWidths = (TeamPairsManager.isMultiDog(showClass.EntryType) ? colWidthsTeam : colWidthsStandard);
                if (currentClassNo != showClass.ClassNo)
                {
                    if (currentClassNo != 0)
                    {

                    }
                    callingListTbl =
                        new PdfPTable(colWidths)
                        {
                            HeaderRows = 2
                        };
                }
                string tmp;
                if (TeamPairsManager.isMultiDog(showClass.EntryType) || showClass.EntryType == 10)
                {
                    tmp =
                        $"Ring No:{currentRing.RingNo}   Class No:{showClass.ClassNo} {showClass.longHeight} {showClass.LongClassName} {showClass.ClassName}";
                }
                else
                {
                    //                    tmp = String.Format("Ring No:{5}   Class No:{0} {1} {2} {3} {6} {7} {4}", showClass.ClassNo, showClass.longHeight, showClass.longCatagory, showClass.LongClassName, grades, currentRing.RingNo, showClass.ClassName, (showClass.Part > 0 ? "Part " + showClass.Part : ""));
                    tmp = $"Ring No:{currentRing.RingNo}   Class No:{showClass.NormalName()}";
                    tmp += $" {(showClass.Part > 0 ? "Part " + showClass.Part : "")}";
                }
                var cell = new PdfPCell(new Phrase(new Chunk(tmp, ClassTitleFont)))
                {
                    Colspan = colWidths.Length,
                    BorderWidth = 0,
                    FixedHeight = 40F
                };
                callingListTbl.AddCell(cell);

                cell = new PdfPCell(new Phrase(new Chunk("", ClassTitleFont)))
                {
                    Colspan = colWidths.Length,
                    BorderWidth = 0
                };
                callingListTbl.AddCell(cell);
                doc.Add(callingListTbl);
                callingListTbl.AddCell(new PdfPCell(new Phrase(new Chunk("RO", headerFont))) { BorderWidth = 0, HorizontalAlignment = Element.ALIGN_RIGHT});

                if (!TeamPairsManager.isMultiDog(showClass.EntryType))
                {
                    callingListTbl.AddCell(new PdfPCell(new Phrase(new Chunk(" ", headerFont))) { BorderWidth = 0 });
                    callingListTbl.AddCell(new PdfPCell(new Phrase(new Chunk("Ring No", headerFont))) { BorderWidth = 0, HorizontalAlignment =  Element.ALIGN_RIGHT});
                }
                callingListTbl.AddCell(new PdfPCell(new Phrase(new Chunk("Handler", headerFont))) { BorderWidth = 0 });
                callingListTbl.AddCell(new PdfPCell(new Phrase(new Chunk("Dog Name", headerFont))) { BorderWidth = 0 });
                doc.Add(callingListTbl);
                int altFlag = 0;
                Color altLine = Color.LIGHT_GRAY;
                callingListTbl = new PdfPTable((TeamPairsManager.isMultiDog(showClass.EntryType) ? colWidthsTeam : colWidths));
                if (TeamPairsManager.isMultiDog(showClass.EntryType))
                {
                    var teamsForClass = multiTeams.Where(t => t.ClassId == showClass.ID).OrderBy(t => t.RO);

                    foreach (var team in teamsForClass)
                    {
                        var altColor = Color.WHITE;
                        if (altFlag % 2 == 0 && showClass.EntryType != 5)
                        {
                            altColor = altLine;
                        }

                        cell = new PdfPCell(new Phrase(new Chunk(team.RO.ToString(), headerHFont)))
                        {
                            BorderWidth = 0,
                            BackgroundColor = altColor
                        };
                        callingListTbl.AddCell(cell);

                        if (TeamPairsManager.isTeam(showClass.EntryType))
                        {
                            cell =
                                new PdfPCell(
                                    new Phrase(new Chunk("Team Name:" + team.TeamDetails.TeamName.Replace("&#39;", "'"),
                                        headerHFont)))
                                {
                                    BackgroundColor = altColor,
                                    BorderWidth = 0
                                };
                            callingListTbl.AddCell(cell);

                            cell =
                                new PdfPCell(
                                    new Phrase(new Chunk("Captain:" + team.TeamDetails.Captain.Replace("&#39;", "'"),
                                        headerHFont)))
                                {
                                    BackgroundColor = altColor,
                                    BorderWidth = 0
                                };
                            callingListTbl.AddCell(cell);

                            cell = new PdfPCell(new Phrase(new Chunk("", headerHFont)))
                            {
                                BackgroundColor = altColor,
                                BorderWidth = 0
                            };
                            callingListTbl.AddCell(cell);
                        }

                        var dogCnt = 0;
                        var handlerPara = new Paragraph();
                        var dogPara = new Paragraph();
                        foreach (var member in team.Members)
                        {
                            if (dogCnt < team.DogCount)
                            {
                                if (dogCnt > 0)
                                {
                                    handlerPara.Add(new Phrase(Chunk.NEWLINE));
                                    dogPara.Add(new Phrase(Chunk.NEWLINE));
                                }

                                handlerPara.Add(new Phrase(new Chunk(Utils.TitleCaseString(member.HandlerName).Replace("&#39;", "'"), font)));
                                dogPara.Add(new Phrase(new Chunk(Utils.TitleCaseString(member.DogName).Replace("&#39;", "'"), font)));
                            }
                            dogCnt++;
                        }
                        cell = new PdfPCell(handlerPara)
                        {
                            BorderWidth = 0,
                            BorderWidthTop = 0,
                            BackgroundColor = altColor
                        };
                        callingListTbl.AddCell(cell);

                        cell = new PdfPCell(dogPara)
                        {
                            BorderWidth = 0,
                            BorderWidthTop = 0,
                            BackgroundColor = altColor
                        };
                        callingListTbl.AddCell(cell);
                        doc.Add(callingListTbl);

                        altFlag++;
                        callingListTbl = new PdfPTable((TeamPairsManager.isMultiDog(showClass.EntryType) ? colWidthsTeam : colWidths));

                        var lineLeft = writer.GetVerticalPosition(false) - doc.BottomMargin;
                        if (lineLeft < 50)
                        {
                            doc.NewPage();
                        }
                    }
                }
                else
                {
                    var callingList = sc.GetCallingList(showId, showClass.ID);
                    foreach (var item in callingList)
                    {

                        Color altColor = Color.WHITE;
                        if (altFlag % 2 == 0 && showClass.EntryType != 5)
                        {
                            altColor = altLine;
                        }

                        callingListTbl.AddCell(new PdfPCell(new Phrase(new Chunk($"{item.Ro}", font)))
                        {
                            BorderWidth = 0,
                            BackgroundColor = altColor,
                            HorizontalAlignment = Element.ALIGN_RIGHT
                        });

                        var borderWidth = 0;
                        callingListTbl.AddCell(new PdfPCell(new Phrase(new Chunk(item.Lho == 0 ? "" : "LHO", font)))
                        {
                            HorizontalAlignment = Element.ALIGN_RIGHT,
                            BackgroundColor = altColor,
                            BorderWidth = borderWidth
                        });
                        callingListTbl.AddCell(new PdfPCell(new Phrase(new Chunk($"{item.RingNumber}", font)))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER,
                            BackgroundColor = altColor,
                            BorderWidth = borderWidth
                        });

                        var handlerName = Utils.TitleCaseString(item.Name);
                        User user;
                        var namePhrase = new Phrase();
                        var us = new UserShows(item.UserId, showId);
                        if (item.DefaultHandlerId > 0)
                        {
                            user = new User(item.DefaultHandlerId);
                            handlerName = user.Name;
                        }
                        if (item.AltHandlerId > 0)
                        {
                            user = new User(item.AltHandlerId);
                            handlerName = user.Name;
                        }

                        if (us.HandlerType == (int)Core.Enums.DiscountTypes.Member)
                        {
                            namePhrase.Add(new Chunk("(M)", fontBold));
                            namePhrase.Add(new Chunk(Utils.TitleCaseString(handlerName), fontBold));
                        }
                        else
                        {
                            namePhrase.Add(new Chunk(Utils.TitleCaseString(handlerName), font));
                        }
                        cell = new PdfPCell(namePhrase)
                        {
                            BackgroundColor = altColor,
                            BorderWidth = borderWidth
                        };
                        callingListTbl.AddCell(cell);

                        cell =
                            new PdfPCell(
                                new Phrase(new Chunk(Fpp.Core.Utils.TitleCaseString(item.KcName), font)))
                            {
                                BackgroundColor = altColor,
                                BorderWidth = borderWidth
                            };
                        callingListTbl.AddCell(cell);

                        altFlag++;
                    }
                    doc.Add(callingListTbl);
                }
                doc.NewPage();
            }
            return ret;
        }
        public void ScribeSheets(Document doc, int showId, int ringId, PdfWriter writer )
        {
            var font = new Font(Font.HELVETICA, 10, Font.NORMAL, Color.BLACK);
            var smallFont = new Font(Font.HELVETICA, 8, Font.NORMAL, Color.BLACK);
            var totalsFont = new Font(Font.HELVETICA, 14, Font.BOLD, Color.BLACK);
            var bigBoyFont = new Font(Font.HELVETICA, 20, Font.BOLD, Color.BLACK);
            var bigBoyFont2 = new Font(Font.HELVETICA, 25, Font.BOLD, Color.BLACK);
            var blankCell = new PdfPCell(new Phrase(new Chunk("", font)));
            var sc = new ShowClasses();
            var currentRing = new Rings(ringId);
            var multiClasses = TeamPairsManager.GetTeamPairClasses(showId);
            var multiTeams = TeamPairsManager.GetTeamPairsForShow(showId, multiClasses);
            var showClasses = ShowClasses.GetAllClassesForShowRing(showId, ringId);
            foreach (var showClass in showClasses)
            {
                var callingList = sc.GetCallingList(showId, showClass.ID);

                var grades = showClass.Grades;
                if (grades.Length == 1)
                {
                    grades = "Grade " + grades;
                }
                else
                {
                    grades = "Grades " + grades[0] + "-" + grades[grades.Length - 1];
                }
                var ptable = new PdfPTable(1);
                var tmp = $"Class {showClass.ClassNo}";
                var cell = new PdfPCell(new Phrase(new Chunk(tmp, bigBoyFont2)))
                {
                    BorderWidth = 0,
                    Padding = 5,
                    HorizontalAlignment = Element.ALIGN_MIDDLE,
                    VerticalAlignment = Element.ALIGN_CENTER
                };
                ptable.AddCell(cell);

                if (showClass.EntryType == 10)
                {
                    tmp = $"{showClass.longHeight} {showClass.LongClassName} {showClass.ClassName}";
                }
                else
                {
                    tmp =
                        $"{showClass.NormalName(withClassNo: false)} {(showClass.Part > 0 ? "Part " + showClass.Part : "")} ";
                }
                cell = new PdfPCell(new Phrase(new Chunk(tmp, totalsFont)))
                {
                    BorderWidth = 0,
                    Padding = 5,
                    HorizontalAlignment = Element.ALIGN_MIDDLE,
                    VerticalAlignment = Element.ALIGN_CENTER
                };
                ptable.AddCell(cell);

                if (showClass.EntryType != 10)
                {
                    tmp = $"{grades}";
                    cell = new PdfPCell(new Phrase(new Chunk(tmp, totalsFont)))
                    {
                        BorderWidth = 0,
                        Padding = 5,
                        FixedHeight = 100f,
                        HorizontalAlignment = Element.ALIGN_MIDDLE,
                        VerticalAlignment = Element.ALIGN_CENTER
                    };
                    ptable.AddCell(cell);
                }

                tmp = $"Ring {currentRing.RingNo}";
                cell = new PdfPCell(new Phrase(new Chunk(tmp, totalsFont)))
                {
                    BorderWidth = 0,
                    Padding = 5,
                    FixedHeight = 30f,
                    HorizontalAlignment = Element.ALIGN_MIDDLE
                };
                ptable.AddCell(cell);

                tmp = $"Ring Order = {showClass.Position}";
                cell = new PdfPCell(new Phrase(new Chunk(tmp, totalsFont)))
                {
                    BorderWidth = 0,
                    Padding = 5,
                    FixedHeight = 30f,
                    HorizontalAlignment = Element.ALIGN_MIDDLE
                };
                ptable.AddCell(cell);

                doc.Add(ptable);
                doc.NewPage();

                if (TeamPairsManager.isMultiDog(showClass.EntryType))
                {
                    float[] colWidths = { 300, 150 };
                    var callingListTbl = new PdfPTable(colWidths);

                    var teamsForClass = multiTeams.Where(t => t.ClassId == showClass.ID).OrderBy(t => t.RO);
                    foreach (var team in teamsForClass)
                    {

                        tmp = $"Class {showClass.NormalName()}: {(showClass.Part > 0 ? "Part " + showClass.Part : "")}";
                        cell = new PdfPCell(new Phrase(new Chunk(tmp, notSoBigFont)))
                        {
                            BorderWidth = 2,
                            BorderColorRight = Color.BLACK,
                            BorderColorBottom = Color.BLACK,
                            Padding = 5,
                            PaddingTop = 1,
                            PaddingLeft = 2,
                            FixedHeight = 50f
                        };
                        callingListTbl.AddCell(cell);

                        cell = new PdfPCell(new Phrase(new Chunk(team.RO.ToString(), bigBoyFont)))
                        {
                            BorderWidth = 2,
                            BorderColorLeft = Color.BLACK,
                            BorderColorBottom = Color.BLACK,
                            HorizontalAlignment = Element.ALIGN_CENTER,
                            Padding = 5
                        };
                        callingListTbl.AddCell(cell);

                        cell = new PdfPCell(new Phrase(new Chunk("Course Time", notSoBigFont)))
                        {
                            BorderWidth = 2,
                            Padding = 5,
                            BorderColorRight = Color.BLACK,
                            HorizontalAlignment = Element.ALIGN_RIGHT
                        };
                        callingListTbl.AddCell(cell);
                        cell = new PdfPCell(new Phrase(new Chunk(" ", notSoBigFont)))
                        {
                            BorderWidth = 2,
                            Padding = 5,
                            BorderColorRight = Color.BLACK,
                            HorizontalAlignment = Element.ALIGN_RIGHT
                        };
                        callingListTbl.AddCell(cell);

                        if (TeamPairsManager.isTeam(showClass.EntryType))
                        {
                            cell =
                                new PdfPCell(
                                    new Phrase(new Chunk(team.TeamDetails.TeamName.Replace("&#39;", "'"), bold12)))
                                {
                                    PaddingBottom = 5,
                                    BorderWidth = 0,
                                    BorderWidthBottom = 1,
                                    HorizontalAlignment = Element.ALIGN_CENTER,
                                    BorderColor = Color.LIGHT_GRAY,
                                    Colspan = 2
                                };
                            callingListTbl.AddCell(cell);
                            var dogCnt = 0;
                            var reserves = "";
                            foreach (var md in team.Members)
                            {
                                if (dogCnt < team.DogCount)
                                {
                                    cell = new PdfPCell(new Phrase(new Chunk(Fpp.Core.Utils.TitleCaseString(md.DogName), normal8)));
                                    cell.BorderWidth = 0;
                                    callingListTbl.AddCell(cell);

                                    cell = new PdfPCell(new Phrase(new Chunk(Fpp.Core.Utils.TitleCaseString(md.HandlerName), normal8)));
                                    cell.BorderWidth = 0;
                                    cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                                    callingListTbl.AddCell(cell);
                                }
                                else
                                {
                                    if (md.HandlerName.Length > 0  )
                                    {
                                        if (reserves.Length > 0) reserves += ",";
                                        reserves +=
                                            $"{Utils.TitleCaseString(md.HandlerName)} & {Utils.TitleCaseString(md.DogName)}";
                                    }
                                }
                                dogCnt++;
                            }
                            if (reserves.Length > 0)
                            {
                                cell = new PdfPCell(new Phrase(new Chunk("Reserves:" + reserves, italic8)))
                                {
                                    BorderWidth = 0,
                                    Colspan = 2
                                };
                                callingListTbl.AddCell(cell);
                            }
                            doc.Add(callingListTbl);

                            callingListTbl = new PdfPTable(colWidths);
                            var linecnt = writer.GetVerticalPosition(false) - doc.BottomMargin;
                            cell = new PdfPCell
                            {
                                BorderWidth = 0,
                                Colspan = 2,
                                FixedHeight = writer.PageSize.Height - linecnt - 60
                            };
                            callingListTbl.AddCell(cell);
                            doc.Add(callingListTbl);

                        }
                        else
                        {
                            var memberTable = new PdfPTable(new float[] { 300, 300 });
                            var memberCell = new PdfPCell(memberTable)
                            {
                                BorderWidth = 0,
                                Colspan = 2,
                                PaddingBottom = 10
                            };
                            var dogCnt = 0;
                            foreach (var md in team.Members)
                            {
                                if (dogCnt < team.DogCount)
                                {
                                    cell =
                                        new PdfPCell(
                                            new Phrase(new Chunk(Fpp.Core.Utils.TitleCaseString(md.HandlerName), font)))
                                        {
                                            BorderWidth = 0
                                        };
                                    memberTable.AddCell(cell);

                                    cell =
                                        new PdfPCell(
                                            new Phrase(new Chunk(Fpp.Core.Utils.TitleCaseString(md.DogName), font)))
                                        {
                                            BorderWidth = 0
                                        };
                                    memberTable.AddCell(cell);
                                }
                                dogCnt++;
                            }
                            memberCell.FixedHeight = 180f;
                            callingListTbl.AddCell(memberCell);
                            doc.Add(callingListTbl);
                        }

                        callingListTbl = new PdfPTable(colWidths);
                        cell = new PdfPCell(new Phrase(new Chunk("Time", notSoBigFont)))
                        {
                            BorderWidth = 2,
                            BorderColorRight = Color.BLACK,
                            BorderColorBottom = Color.BLACK,
                            Padding = 5,
                            HorizontalAlignment = Element.ALIGN_CENTER
                        };
                        callingListTbl.AddCell(cell);
                        callingListTbl.AddCell(blankCell);

                        cell = new PdfPCell(new Phrase(new Chunk("Course Faults", notSoBigFont)))
                        {
                            BorderWidth = 2,
                            BorderColorRight = Color.BLACK,
                            BorderColorBottom = Color.BLACK,
                            Padding = 5,
                            HorizontalAlignment = Element.ALIGN_CENTER
                        };
                        callingListTbl.AddCell(cell);
                        callingListTbl.AddCell(blankCell);

                        cell = new PdfPCell(new Phrase(new Chunk("Time Faults", notSoBigFont)))
                        {
                            BorderWidth = 2,
                            BorderColorRight = Color.BLACK,
                            BorderColorBottom = Color.BLACK,
                            Padding = 5,
                            HorizontalAlignment = Element.ALIGN_CENTER
                        };
                        callingListTbl.AddCell(cell);
                        callingListTbl.AddCell(blankCell);

                        cell = new PdfPCell(new Phrase(new Chunk("Totals Faults", notSoBigFont)))
                        {
                            BorderWidth = 2,
                            BorderColorRight = Color.BLACK,
                            BorderColorBottom = Color.BLACK,
                            Padding = 5,
                            HorizontalAlignment = Element.ALIGN_CENTER
                        };
                        callingListTbl.AddCell(cell);
                        callingListTbl.AddCell(blankCell);
                        doc.Add(callingListTbl);
                        doc.NewPage();

                        doc.NewPage();
                        callingListTbl = new PdfPTable(colWidths);

                    }
                    doc.Add(callingListTbl);

                }
                else {
                    foreach (var item in callingList)
                    {
                        if (item.Category == 0 && showClass.EntryType != 10)
                        {
                            var tbl = new PdfPTable(1);
                            tmp = item.Grade == 99 ? "Veteran" : $"Grade {item.Grade}";
                            cell = new PdfPCell(new Phrase(new Chunk(tmp, bigBoyFont2)))
                            {
                                BackgroundColor = Color.LIGHT_GRAY,
                                BorderWidth = 2,
                                Padding = 9,
                                PaddingTop = 4,
                                HorizontalAlignment = Element.ALIGN_RIGHT
                            };
                            tbl.AddCell(cell);
                            doc.Add(tbl);
                        }

                        float[] colWidths = { 300, 150 };
                        var callingListTbl = new PdfPTable(colWidths);
                        tmp = showClass.EntryType == 10 ?
                            $"Class {showClass.ClassNo}: {showClass.longHeight} {showClass.LongClassName} {showClass.ClassName}"
                            : $"Class {showClass.ClassNo}: {showClass.NormalName(withClassNo: false)} {(showClass.Part > 0 ? "Part " + showClass.Part : "")}";
                        cell = new PdfPCell(new Phrase(new Chunk(tmp, notSoBigFont)))
                        {
                            BorderWidth = 2,
                            BorderColorRight = Color.BLACK,
                            BorderColorBottom = Color.BLACK,
                            Padding = 5,
                            PaddingTop = 1,
                            PaddingLeft = 2,
                            FixedHeight = 50f
                        };
                        callingListTbl.AddCell(cell);

                        cell = new PdfPCell(new Phrase(new Chunk($"{item.Ro}", bigBoyFont)))
                        {
                            BorderWidth = 2,
                            BorderColorLeft = Color.BLACK,
                            BorderColorBottom = Color.BLACK,
                            HorizontalAlignment = Element.ALIGN_CENTER,
                            Padding = 5
                        };
                        callingListTbl.AddCell(cell);

                        cell = new PdfPCell(new Phrase(new Chunk("Course Time", notSoBigFont)))
                        {
                            BorderWidth = 2,
                            Padding = 5,
                            BorderColorRight = Color.BLACK,
                            HorizontalAlignment = Element.ALIGN_RIGHT
                        };
                        callingListTbl.AddCell(cell);

                        cell = new PdfPCell(new Phrase(new Chunk("", notSoBigFont)))
                        {
                            BorderWidth = 2,
                            Padding = 5,
                            BorderColorBottom = Color.BLACK
                        };
                        callingListTbl.AddCell(cell);

                        var handlerName = item.Name;
                        User user;
                        if (item.DefaultHandlerId > 0)
                        {
                            user = new User(item.DefaultHandlerId);
                            handlerName = user.Name;
                        }
                        if (item.AltHandlerId> 0)
                        {
                            user = new User(item.AltHandlerId);
                            handlerName = user.Name;
                        }

                        if (showClass.EntryType == 5 || showClass.EntryType == 9)
                        {
                            cell =
                                new PdfPCell(new Phrase(new Chunk($"{Utils.TitleCaseString(handlerName)}", smallFont)))
                                {
                                    BorderWidth = 0,
                                    Colspan = 1,
                                    HorizontalAlignment = Element.ALIGN_LEFT
                                };
                            callingListTbl.AddCell(cell);

                            cell = new PdfPCell(new Phrase(new Chunk(
                                $"{Utils.TitleCaseString(item.KcName),-10}", smallFont)))
                            {
                                Colspan = 1,
                                HorizontalAlignment = Element.ALIGN_RIGHT,
                                BorderWidth = 0
                            };
                        }
                        else
                        {
                            cell =
                                new PdfPCell(new Phrase(new Chunk($"{Utils.TitleCaseString(handlerName)}", notSoBigFont)))
                                {
                                    BorderWidth = 0,
                                    Colspan = 2
                                };
                            callingListTbl.AddCell(cell);
                            callingListTbl.AddCell(new PdfPCell(new Phrase(new Chunk(
                                $"{item.RingNumber,-10} {Utils.TitleCaseString(item.KcName)}",
                                notSoBigFont)))
                            {
                                BorderWidth = 0,
                                Colspan = 2
                            });

                            callingListTbl.AddCell(new PdfPCell(new Phrase(new Chunk($"{item.Breed}", notSoBigFontItalic))) { BorderWidth = 0, Colspan = 2});

                            cell = new PdfPCell(new Phrase(new Chunk($"{(item.Lho == 0 ? "" : "Lower Height")}", Bold18Black)))
                            {
                                BorderWidth = 0,
                                Colspan = 2,
                                PaddingTop = 10
                            };
                        }

                        int[] extendHeight = { 1, 2, 3, 7, 10, 11 };
                        if (extendHeight.Any(h => h == showClass.EntryType))
                        {
                            cell.FixedHeight = 160f;
                        }
                        cell.Colspan = 2;
                        callingListTbl.AddCell(cell);

                        doc.Add(callingListTbl);
                        callingListTbl = new PdfPTable(colWidths);
                        cell = new PdfPCell(new Phrase(new Chunk("Time", notSoBigFont)))
                        {
                            BorderWidth = 2,
                            BorderColorRight = Color.BLACK,
                            BorderColorBottom = Color.BLACK,
                            Padding = 5,
                            HorizontalAlignment = Element.ALIGN_CENTER
                        };
                        callingListTbl.AddCell(cell);
                        callingListTbl.AddCell(blankCell);

                        cell = new PdfPCell(new Phrase(new Chunk("Course Faults", notSoBigFont)))
                        {
                            BorderWidth = 2,
                            BorderColorRight = Color.BLACK,
                            BorderColorBottom = Color.BLACK,
                            Padding = 5,
                            HorizontalAlignment = Element.ALIGN_CENTER
                        };
                        callingListTbl.AddCell(cell);
                        callingListTbl.AddCell(blankCell);

                        cell = new PdfPCell(new Phrase(new Chunk("Time Faults", notSoBigFont)))
                        {
                            BorderWidth = 2,
                            BorderColorRight = Color.BLACK,
                            BorderColorBottom = Color.BLACK,
                            Padding = 5,
                            HorizontalAlignment = Element.ALIGN_CENTER
                        };
                        callingListTbl.AddCell(cell);
                        callingListTbl.AddCell(blankCell);

                        cell = new PdfPCell(new Phrase(new Chunk("Totals Faults", notSoBigFont)))
                        {
                            BorderWidth = 2,
                            BorderColorRight = Color.BLACK,
                            BorderColorBottom = Color.BLACK,
                            Padding = 5,
                            HorizontalAlignment = Element.ALIGN_CENTER
                        };
                        callingListTbl.AddCell(cell);
                        callingListTbl.AddCell(blankCell);
                        doc.Add(callingListTbl);
                        doc.NewPage();

                    }
                }
            }
        }
Exemple #6
0
 public override void Write(PdfWriter writer, Document doc) {
     ColumnText c = new ColumnText(writer.DirectContent);
     float verticalPosition = writer.GetVerticalPosition(false);
     c.SetSimpleColumn(new Phrase(new Chunk(" ").SetLocalDestination(name)), 1,
             verticalPosition - 5, 6, verticalPosition, 5, Element.ALIGN_LEFT);
     try {
         c.Go();
     }
     catch (DocumentException e) {
         throw new RuntimeWorkerException(e);
     }
 }
        static void addUrgencias(Document doc, PdfWriter writer, ExpensasEdificio expensa, System.Drawing.Image _24, System.Drawing.Image _tijera)
        {
            Image img = iTextSharp.text.Image.GetInstance(_24, System.Drawing.Imaging.ImageFormat.Png);
            img.SetAbsolutePosition(milimetroToPoint(12), doc.PageSize.Height - milimetroToPoint(9.5f) - milimetroToPoint(7));
            img.ScaleToFit(milimetroToPoint(9.5f), milimetroToPoint(9.5f));

            PdfPTable t = new PdfPTable(4);
            t.WidthPercentage = 85;
            float[] widths = new float[] { 8.5f, 35f, 35f, 35f };
            t.SetWidths(widths);

            PdfPCell c = new PdfPCell();
            Paragraph p;

            c.PaddingTop = 10;
            c.PaddingLeft = 0;
            c.Border = 0;
            c.AddElement(img);
            t.WidthPercentage = 100;
            t.AddCell(c);

            int leading = 9;
            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, "Urgencias", calibri8B);
            c.AddElement(p);

            int pos = 0;
            foreach (Proveedor prov in expensa.Proveedores)
            {
                p = new Paragraph(leading, prov.cargo + ": " + prov.nombre + " - " + prov.telefono, calibri8N);
                c.AddElement(p);
                pos++;
                if (pos == 3)
                {
                    t.AddCell(c);
                    c = new PdfPCell();
                    c.Border = 0;
                    c.AddElement(new Paragraph(" ", calibri8N));
                    pos = 0;
                }
            }
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            for (int i = 0; i <= (expensa.Proveedores.Count % 3); i++)
                t.AddCell(c);

            doc.Add(t);

            doc.Add(new Paragraph(8, " "));

            Image tijera = iTextSharp.text.Image.GetInstance(_tijera, System.Drawing.Imaging.ImageFormat.Png);
            //tijera.SetAbsolutePosition(milimetroToPoint(12), doc.PageSize.Height - milimetroToPoint(9.5f) - milimetroToPoint(7));
            tijera.ScaleToFit(milimetroToPoint(9f), milimetroToPoint(9f));
            tijera.SetAbsolutePosition(40, writer.GetVerticalPosition(true) - 10);
            writer.DirectContent.AddImage(tijera);

            doc.Add(new Paragraph(5, "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"));
            doc.Add(tijera);
        }
Exemple #8
0
        private void GenerarPDF(CabezalRecibo recibo)
        {
            try
            {
                gridViewDocumentos.AllowPaging = false;
                Document doc = new Document(PageSize.LETTER);
                // Indicamos donde vamos a guardar el documento
                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                //PdfWriter writer = PdfWriter.GetInstance(doc,new FileStream(@"C:\recibo.pdf", FileMode.Create));
                doc.AddTitle("Recibo Pago");
                doc.AddCreator("E&E Integra");
                iTextSharp.text.pdf.PdfWriter writer = iTextSharp.text.pdf.PdfWriter.GetInstance(doc, ms);
                doc.Open();
                // Creamos el tipo de Font que vamos utilizar
                iTextSharp.text.Font _tituloFont  = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 14, iTextSharp.text.Font.BOLD, BaseColor.BLACK);
                iTextSharp.text.Font _tituloFont2 = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 14, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
                iTextSharp.text.Font texto        = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 12, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
                iTextSharp.text.Font cuota_font   = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 9, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
                string imageURL           = Server.MapPath("~//Imagenes") + "\\logo.png";
                iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(imageURL);
                jpg.Alignment = iTextSharp.text.Image.TEXTWRAP | iTextSharp.text.Image.ALIGN_LEFT;
                jpg.ScaleAbsolute(177f, 100f);
                doc.Add(jpg);
                // Escribimos el encabezamiento en el documento
                Paragraph paragraph1 = new Paragraph(@"                            RUT: " + Session["rut"].ToString(), _tituloFont);
                paragraph1.Alignment = Element.ALIGN_JUSTIFIED;
                doc.Add(paragraph1);
                Paragraph paragraph2 = new Paragraph(@"                            Recibo Oficial", _tituloFont);
                paragraph2.Alignment = Element.ALIGN_JUSTIFIED;
                doc.Add(paragraph2);
                Paragraph paragraph3 = new Paragraph(@"                            Nro. Recibo: " + recibo.Numero.ToString(), _tituloFont2);
                paragraph3.Alignment = Element.ALIGN_JUSTIFIED;
                doc.Add(paragraph3);

                Paragraph paragraph4 = new Paragraph(@"                            Moneda: " + recibo.Moneda, _tituloFont2);
                paragraph4.Alignment = Element.ALIGN_JUSTIFIED;
                doc.Add(paragraph4);

                Paragraph paragraph5 = new Paragraph(@"                            Importe " + recibo.Importe, _tituloFont);
                paragraph5.Alignment = Element.ALIGN_JUSTIFIED;
                doc.Add(paragraph5);
                doc.Add(Chunk.NEWLINE);
                doc.Add(Chunk.NEWLINE);
                doc.Add(Chunk.NEWLINE);

                String    nom        = recibo.cliente.Nombre;
                Paragraph paragraph6 = new Paragraph(@"Recibimos de " + nom + " la cantidad de " + recibo.Importe + " por concepto de pago de deuda");
                paragraph6.Alignment = Element.ALIGN_LEFT;
                doc.Add(paragraph6);
                doc.Add(Chunk.NEWLINE);

                Paragraph paragraph7 = new Paragraph(@"Observaciones:", _tituloFont);
                paragraph7.Alignment = Element.ALIGN_LEFT;
                doc.Add(paragraph7);
                String resultString = "";
                if (!String.IsNullOrEmpty(recibo.Observaciones))
                {
                    resultString = Regex.Replace(recibo.Observaciones, @"^\s+$[\r\n]*", "", RegexOptions.Multiline);
                }

                Paragraph paragraph8 = new Paragraph(@resultString, cuota_font);
                paragraph8.Alignment = Element.ALIGN_LEFT;
                doc.Add(paragraph8);
                if (!String.IsNullOrEmpty(recibo.MotivoAnulacion))
                {
                    Paragraph paragraph9 = new Paragraph(@"Motivo Anulación:", _tituloFont);
                    paragraph9.Alignment = Element.ALIGN_LEFT;
                    doc.Add(paragraph9);
                    String    anulacionString = Regex.Replace(recibo.MotivoAnulacion, @"^\s+$[\r\n]*", "", RegexOptions.Multiline);
                    Paragraph paragraph10     = new Paragraph(@anulacionString, cuota_font);
                    paragraph10.Alignment = Element.ALIGN_LEFT;
                    doc.Add(paragraph10);
                }
                doc.Add(Chunk.NEWLINE);


                Paragraph paragraph11 = new Paragraph(@"Paysandú, " + recibo.Fecha.Day + " de " + MonthName(recibo.Fecha.Month) + " de " + recibo.Fecha.Year);
                paragraph11.Alignment = Element.ALIGN_RIGHT;
                doc.Add(paragraph11);

                float antes = writer.GetVerticalPosition(true);
                float diff  = antes - 353;
                for (int i = 0; i < diff / 20; i++)
                {
                    doc.Add(Chunk.NEWLINE);
                }
                doc.Add(jpg);
                doc.Add(Chunk.NEWLINE);
                doc.Add(paragraph1);
                doc.Add(paragraph2);
                doc.Add(paragraph3);
                doc.Add(paragraph4);

                doc.Add(paragraph5);
                doc.Add(Chunk.NEWLINE);
                doc.Add(Chunk.NEWLINE);
                doc.Add(Chunk.NEWLINE);

                doc.Add(paragraph6);
                doc.Add(Chunk.NEWLINE);
                doc.Add(paragraph7);
                doc.Add(paragraph8);
                if (!String.IsNullOrEmpty(recibo.MotivoAnulacion))
                {
                    Paragraph paragraph9 = new Paragraph(@"Motivo Anulación:", _tituloFont);
                    paragraph9.Alignment = Element.ALIGN_LEFT;
                    doc.Add(paragraph9);
                    String    anulacionString = Regex.Replace(recibo.MotivoAnulacion, @"^\s+$[\r\n]*", "", RegexOptions.Multiline);
                    Paragraph paragraph10     = new Paragraph(@anulacionString, cuota_font);
                    paragraph10.Alignment = Element.ALIGN_LEFT;
                    doc.Add(paragraph10);
                }
                doc.Add(Chunk.NEWLINE);
                doc.Add(paragraph11);

                doc.Close();
                byte[] Result = ms.ToArray();
                writer.Close();
                Sistema.GetInstancia().PDFActual = Result;
                Sistema.GetInstancia().AumentarNroRecibo(Session["rut"].ToString());
                // Session["pdf"] = Result;
                gridViewDocumentos.AllowPaging = true;
                if (Sistema.GetInstancia().PDFActual != null)
                {
                    //Response.Redirect("VisorPDFReportes.aspx");
                    Response.Write("<script>");
                    Response.Write("window.open('VisorPDFReportes.aspx', '_blank');");
                    Response.Write("</script>");
                }
            }
            catch { }
        }