GetTop() public method

Returns the upper right y-coordinate, considering a given margin.
public GetTop ( float margin ) : float
margin float a margin
return float
Exemplo n.º 1
0
        /// <summary>
        /// Gets the contents text from page to put in TOC.
        /// </summary>
        /// <returns>The name of the page.</returns>
        /// <param name="pdfPath">The Pdf to read from.</param>
        /// <param name="page">The pages to read from.</param>
        public static string GetContentsTextFromPage(String pdfPath, int page)
        {
            PdfReader    reader = new PdfReader(pdfPath);
            StringWriter output = new StringWriter();

            //Create rectangle to read from header
            Rectangle mediabox = reader.GetPageSize(page);
            float     llx      = mediabox.GetRight(10f) - 100f;
            float     urx      = mediabox.GetRight(0f);
            float     lly      = mediabox.GetTop(10f) - 50f;
            float     ury      = mediabox.GetTop(0f);
            Rectangle rect     = new Rectangle(llx, lly, urx, ury);

            //The header contains the name of the page. Read from Heaedr.
            RenderFilter            regionFilter = new RegionTextRenderFilter(rect);
            ITextExtractionStrategy strategy     = new FilteredTextRenderListener(
                new LocationTextExtractionStrategy(), regionFilter);

            output.WriteLine(PdfTextExtractor.GetTextFromPage(reader, page, strategy));
            Console.WriteLine(output.ToString());
            string ret = output.ToString();

            //Remove newline characters
            return(Regex.Replace(ret, @"\t|\n|\r", ""));
        }
Exemplo n.º 2
0
        private static void ConfiguraAparenciaAssinatura(PdfSignatureAppearance signatureAppearance, string Reason, string Contact, string Location, string Creator, Bitmap bmp, float Altura, float Largura, float X, float Y, int Rotation, int Pagina, PdfReader pdfReader)
        {
            iTextSharp.text.Image pic = iTextSharp.text.Image.GetInstance(bmp, System.Drawing.Imaging.ImageFormat.Jpeg);

            signatureAppearance.Reason                 = Reason;
            signatureAppearance.Contact                = Contact;
            signatureAppearance.Location               = "Indústrias Nucleares do Brasil S/A - INB";
            signatureAppearance.SignatureCreator       = "Assinador da INB - Desenvolvimento Interno";
            signatureAppearance.SignatureGraphic       = pic;
            signatureAppearance.SignatureRenderingMode = PdfSignatureAppearance.RenderingMode.GRAPHIC;


            float Left, Top;
            float Width, Height;
            float LarguraAssinatura = Largura;
            float AlturaAssinatura = Altura;
            float X_Ajustado, Y_Ajustado;

            iTextSharp.text.Rectangle cropBox = pdfReader.GetCropBox(Pagina);
            iTextSharp.text.Rectangle oRetangulo;
            if (Rotation == 90 || Rotation == 270)
            {
                X_Ajustado = (float)X;
                Y_Ajustado = (float)Y;

                if (Rotation == 270)
                {
                    Y_Ajustado -= 5;
                    Top         = cropBox.GetLeft(X_Ajustado);
                    Width       = cropBox.GetLeft(X_Ajustado + Largura);
                    Left        = cropBox.GetRight(Y_Ajustado);
                    Height      = cropBox.GetRight(Y_Ajustado + Altura);
                    oRetangulo  = new iTextSharp.text.Rectangle(Top, Left, Width, Height);
                }
                else
                {
                    Y_Ajustado -= 5;
                    Top         = cropBox.GetRight(X_Ajustado);
                    Width       = cropBox.GetRight(X_Ajustado + Largura);
                    Left        = cropBox.GetLeft(Y_Ajustado);
                    Height      = cropBox.GetLeft(Y_Ajustado + Altura);
                    oRetangulo  = new iTextSharp.text.Rectangle(Top, Left, Width, Height);
                }
            }
            else
            {
                X_Ajustado = (float)X;
                Y_Ajustado = (float)Y - 5;
                Left       = cropBox.GetLeft(X_Ajustado);
                Top        = cropBox.GetTop(Y_Ajustado);
                Width      = cropBox.GetLeft(X_Ajustado + LarguraAssinatura);
                Height     = cropBox.GetTop(Y_Ajustado + AlturaAssinatura);
                oRetangulo = new iTextSharp.text.Rectangle(Left, Height, Width, Top);
            }
            signatureAppearance.SetVisibleSignature(oRetangulo, Pagina, "sig" + DateTime.Now.ToString("ddMMyyHHmmss"));
        }
Exemplo n.º 3
0
 //creat 2 - line weight
 private void equalline(iTextSharp.text.Rectangle pagesize, int toTheTop)
 {
     cb.EndText();
     cb.SetColorStroke(new BaseColor(0x32, 0x5a, 0x75));
     cb.MoveTo(pagesize.GetLeft(40), pagesize.GetTop(toTheTop - 5));
     cb.LineTo(pagesize.GetRight(40), pagesize.GetTop(toTheTop - 5));
     cb.SetLineWidth(2f);
     cb.Stroke();
     cb.BeginText();
 }
Exemplo n.º 4
0
    void IPdfPCellEvent.CellLayout(PdfPCell cell, iTextSharp.text.Rectangle position, PdfContentByte[] canvases)
    {
        PdfContentByte canvas    = canvases[PdfPTable.TEXTCANVAS];
        float          x         = 0;
        float          y         = 0;
        int            alignment = 0;

        switch (pos)
        {
        case "TOP_LEFT":
            x         = position.GetLeft(3);
            y         = position.GetTop(content.Leading);
            alignment = Element.ALIGN_LEFT;
            break;

        case "TOP_RIGHT":
            x         = position.GetRight(3);
            y         = position.GetTop(content.Leading);
            alignment = Element.ALIGN_RIGHT;
            break;

        case "BOTTOM_LEFT":
            x         = position.GetLeft(3);
            y         = position.GetBottom(3);
            alignment = Element.ALIGN_LEFT;
            break;

        case "BOTTOM_RIGHT":
            x         = position.GetRight(3);
            y         = position.GetBottom(3);
            alignment = Element.ALIGN_RIGHT;
            break;

        case "CENTER_TOP":
            x         = position.GetRight(3) + position.GetLeft(3) / 2;
            y         = position.GetTop(3);
            alignment = Element.ALIGN_RIGHT;
            break;

        case "CENTER_BOTTOM":
            x         = position.GetRight(3) + position.GetLeft(3) / 2;
            y         = position.GetBottom(3);
            alignment = Element.ALIGN_RIGHT;
            break;

        case "CENTER_MIDDLE":
            x         = position.GetRight(3) + position.GetLeft(3) / 2;
            y         = x;
            alignment = Element.ALIGN_RIGHT;
            break;
        }
        ColumnText.ShowTextAligned(canvas, alignment, content, x, y, 0);
    }
Exemplo n.º 5
0
        //create 1 - line weight
        private void line(iTextSharp.text.Rectangle pagesize, int toTheTop, Boolean summary)
        {
            cb.EndText();
            cb.SetColorStroke(new BaseColor(0x66, 0x83, 0x97));
            cb.MoveTo(pagesize.GetLeft(40), pagesize.GetTop(toTheTop - 5));
            cb.LineTo(pagesize.GetRight(40), pagesize.GetTop(toTheTop - 5));
            cb.SetLineWidth(1f);
            cb.Stroke();

            if (!summary)
            {
                cb.BeginText();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Clears the contents of a given page leaving header and footer.
        /// </summary>
        /// <param name="inputPdf">The pdf to modify.</param>
        /// <param name="outputPdf">The pdf created after modification.</param>
        /// <param name="pageNum">The page number to be cleared.</param>
        public static void ClearContents(string inputPdf, string outputPdf, int pageNum)
        {
            using (FileStream fs = new FileStream(outputPdf, FileMode.Create, FileAccess.Write))
            {
                PdfReader  reader  = new PdfReader(inputPdf);
                PdfStamper stamper = new PdfStamper(reader, fs);

                //Get the reactangle leaving header and footer
                Rectangle mediabox = reader.GetPageSize(pageNum);
                float     llx      = mediabox.GetLeft(10f);
                float     urx      = mediabox.GetRight(10f);
                float     lly      = mediabox.GetBottom(10f) + 100f; // Leave footer
                float     ury      = mediabox.GetTop(10f) - 120f;    //Leave header

                List <PdfCleanUpLocation> cleanUpLocations = new List <PdfCleanUpLocation>
                {
                    new PdfCleanUpLocation(pageNum, new iTextSharp.text.Rectangle(llx, lly, urx, ury), BaseColor.WHITE)
                };
                //Use the PdfCleanUpProcessor to clean the page
                PdfCleanUpProcessor cleaner = new PdfCleanUpProcessor(cleanUpLocations, stamper);
                cleaner.CleanUp();
                stamper.Close();
                reader.Close();
            }
        }
Exemplo n.º 7
0
// ---------------------------------------------------------------------------    
    /**
     * @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(
     * com.lowagie.text.pdf.PdfPCell,
     * com.lowagie.text.Rectangle, 
     * com.lowagie.text.pdf.PdfContentByte[]
     * )
     */
    public void CellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] cb)
    {
      parent.AddKid(kid);
      kid.SetWidget(
        new Rectangle(rect.GetLeft(padding), rect.GetBottom(padding),
        rect.GetRight(padding), rect.GetTop(padding)),
        PdfAnnotation.HIGHLIGHT_INVERT
      );
    }
Exemplo n.º 8
0
    /*  public override void OnEndPage(PdfWriter writer, Document document)
     * {
     *     //PdfContentByte cb = writer.DirectContentUnder;
     *
     *     //iTextSharp.text.Image marca = iTextSharp.text.Image.GetInstance(marcaAgua);
     *
     *     //// Calcular la proporcion
     *     //float ancho = marca.Width;
     *     //float alto = marca.Height;
     *     //float proporcion = alto / ancho;
     *
     *     //float positionY = (writer.PageSize.Top / 2) - (alto /2);
     *     //float positionX = (writer.PageSize.Right / 2) - (ancho / 2);
     *
     *
     *     //marca.ScaleAbsoluteWidth(400);
     *     //marca.ScaleAbsoluteHeight(400 * proporcion);
     *
     *     //marca.SetAbsolutePosition(positionX,positionY);
     *     //PdfGState state = new PdfGState();
     *     //state.FillOpacity = 0.2f;
     *     //cb.SetGState(state);
     *     //cb.AddImage(marca);
     *
     *
     *     //PdfPTable tbHeader = new PdfPTable(3);
     *     //tbHeader.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin;
     *     //tbHeader.DefaultCell.Border = 0;
     *
     *     //tbHeader.AddCell(new Paragraph());
     *
     *     //PdfPCell _cell = new PdfPCell(new Paragraph("Listado de Producto"));
     *     //_cell.HorizontalAlignment = Element.ALIGN_CENTER;
     *     //_cell.Border = 0;
     *     //tbHeader.AddCell(_cell);
     *     //tbHeader.AddCell(new Paragraph());
     *
     *     //tbHeader.WriteSelectedRows(0, -1, document.LeftMargin, writer.PageSize.GetTop(document.TopMargin)+40, writer.DirectContent);
     *
     *     //PdfPTable tbFooter = new PdfPTable(3);
     *     //tbFooter.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin;
     *     //tbFooter.DefaultCell.Border = 0;
     *
     *     ////tbFooter.AddCell(new Paragraph());
     *
     *     //// _cell = new PdfPCell(new Paragraph("Vendemos de lo Mejor"));
     *     ////_cell.HorizontalAlignment = Element.ALIGN_CENTER;
     *     ////_cell.Border = 0;
     *     ////tbFooter.AddCell(_cell);
     *
     *     ////_cell = new PdfPCell(new Paragraph("Página " +writer.PageNumber));
     *     ////_cell.HorizontalAlignment = Element.ALIGN_RIGHT;
     *     ////_cell.Border = 0;
     *     ////tbFooter.AddCell(_cell);
     *
     *     ////tbFooter.WriteSelectedRows(0, -1, document.LeftMargin, writer.PageSize.GetBottom(document.BottomMargin) -5, writer.DirectContent);
     *
     *     //// Begin Image
     *
     *     //iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance(logoPath);
     *
     *     //// Calcular la proporcion
     *     // ancho = logo.Width;
     *     // alto = logo.Height;
     *     // proporcion = alto / ancho;
     *
     *     //logo.ScaleAbsoluteWidth(150);
     *     //logo.ScaleAbsoluteHeight(150 * proporcion);
     *
     *     //logo.SetAbsolutePosition(document.LeftMargin, writer.PageSize.GetTop(document.TopMargin)+10);
     *
     *     //// Porcentaje de la imagen
     *
     *     ////logo.ScalePercent(35);
     *     //document.Add(logo);
     *
     *     ////End Image
     * }*/



    public override void OnStartPage(PdfWriter writer, Document document)
    {
        base.OnStartPage(writer, document);
        Rectangle pageSize = document.PageSize;

        if (Title != string.Empty)
        {
            cb.BeginText();
            cb.SetFontAndSize(bf, 15);
            cb.SetRgbColorFill(50, 50, 200);
            cb.SetTextMatrix(pageSize.GetLeft(40), pageSize.GetTop(40));
            cb.ShowText(Title);
            cb.EndText();
        }
        if (HeaderLeft + HeaderRight != string.Empty)
        {
            PdfPTable HeaderTable = new PdfPTable(2);
            HeaderTable.DefaultCell.Border            = 0;
            HeaderTable.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE;
            HeaderTable.TotalWidth = pageSize.Width - 80;
            HeaderTable.SetWidthPercentage(new float[] { 45, 45 }, pageSize);

            PdfPCell HeaderLeftCell = new PdfPCell(new Phrase(8, HeaderLeft, HeaderFont));
            HeaderLeftCell.Padding       = 5;
            HeaderLeftCell.PaddingBottom = 8;
            //   HeaderLeftCell.BorderWidthRight = 0;
            HeaderTable.AddCell(HeaderLeftCell);
            PdfPCell HeaderRightCell = new PdfPCell(new Phrase(8, HeaderRight, HeaderFont));
            HeaderRightCell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
            HeaderRightCell.Padding             = 5;
            HeaderRightCell.PaddingBottom       = 8;
            //     HeaderRightCell.BorderWidthLeft = 0;
            HeaderTable.AddCell(HeaderRightCell);
            cb.SetRgbColorFill(0, 0, 0);
            HeaderTable.WriteSelectedRows(0, -1, pageSize.GetLeft(40), pageSize.GetTop(50), cb);
        }
    }
            public override void OnStartPage(PdfWriter writer, Document document)
            {
                base.OnStartPage(writer, document);

                iTextSharp.text.Rectangle pageSize = document.PageSize;

                if (HeaderRight != string.Empty)
                {
                    PdfPTable HeaderTable = new PdfPTable(2);
                    HeaderTable.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE;
                    HeaderTable.TotalWidth = pageSize.Width - 10;
                    HeaderTable.SetWidthPercentage(new float[] { 45, 45 }, pageSize);

                    PdfPCell HeaderRightCell = new PdfPCell(new Phrase(8, HeaderRight, HeaderFont));
                    HeaderRightCell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                    HeaderRightCell.Border  = 0;
                    HeaderRightCell.Colspan = 2;
                    HeaderTable.AddCell(HeaderRightCell);

                    cb.SetRGBColorFill(0, 0, 0);
                    HeaderTable.WriteSelectedRows(0, -1, pageSize.GetLeft(0), pageSize.GetTop(10), cb);
                }
            }
Exemplo n.º 10
0
 /**
 * @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(com.lowagie.text.pdf.PdfPCell, com.lowagie.text.Rectangle, com.lowagie.text.pdf.PdfContentByte[])
 */
 public void CellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) {
     float sp_left = spacing_left;
     if (float.IsNaN(sp_left)) sp_left = 0f;
     float sp_right = spacing_right;
     if (float.IsNaN(sp_right)) sp_right = 0f;
     float sp_top = spacing_top;
     if (float.IsNaN(sp_top)) sp_top = 0f;
     float sp_bottom = spacing_bottom;
     if (float.IsNaN(sp_bottom)) sp_bottom = 0f;
     Rectangle rect = new Rectangle(position.GetLeft(sp_left), position.GetBottom(sp_bottom), position.GetRight(sp_right), position.GetTop(sp_top));
     rect.CloneNonPositionParameters(this);
     canvases[PdfPTable.BACKGROUNDCANVAS].Rectangle(rect);
     rect.BackgroundColor = null;
     canvases[PdfPTable.LINECANVAS].Rectangle(rect);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Returns the upper right y-coordinate, considering a given margin.
 /// </summary>
 /// <param name="margin">a margin</param>
 /// <returns>the upper right y-coordinate</returns>
 public float GetTop(float margin)
 {
     return(pageSize.GetTop(marginTop + margin));
 }
Exemplo n.º 12
0
        /**
         * @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(com.lowagie.text.pdf.PdfPCell, com.lowagie.text.Rectangle, com.lowagie.text.pdf.PdfContentByte[])
         */
        public void CellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases)
        {
            float sp_left = spacing_left;

            if (float.IsNaN(sp_left))
            {
                sp_left = 0f;
            }
            float sp_right = spacing_right;

            if (float.IsNaN(sp_right))
            {
                sp_right = 0f;
            }
            float sp_top = spacing_top;

            if (float.IsNaN(sp_top))
            {
                sp_top = 0f;
            }
            float sp_bottom = spacing_bottom;

            if (float.IsNaN(sp_bottom))
            {
                sp_bottom = 0f;
            }
            Rectangle rect = new Rectangle(position.GetLeft(sp_left), position.GetBottom(sp_bottom), position.GetRight(sp_right), position.GetTop(sp_top));

            rect.CloneNonPositionParameters(this);
            canvases[PdfPTable.BACKGROUNDCANVAS].Rectangle(rect);
            rect.BackgroundColor = null;
            canvases[PdfPTable.LINECANVAS].Rectangle(rect);
        }
Exemplo n.º 13
0
        public override void OnGenericTag(PdfWriter writer, Document document, iTextSharp.text.Rectangle rect, string text)
        {
            String name = "dest" + (counter++);
            int    page = writer.PageNumber;

            toc.Add(new PageIndex()
            {
                Text = text, Name = name, Page = page
            });
            writer.DirectContent.LocalDestination(name, new PdfDestination(PdfDestination.FITH, rect.GetTop(0)));
        }
Exemplo n.º 14
0
        //make the pdf new func
        private void makepdf(object sender, RoutedEventArgs e)
        {
            //open new doc and create base font for doc
            Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35);
            BaseFont bf  = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

            MySqlDataReader dr  = null;
            MySqlCommand    cmd = null;

            object nme       = main.cb1.SelectedItem;
            string name      = "";
            string date1     = main.dp1.Text;
            string date2     = main.dp2.Text;
            string firstName = "";

            //get name
            if (nme != null)
            {
                name = nme.ToString();
                int spaceIndex = name.IndexOf(" ") + 1;

                firstName = name.Substring(0, spaceIndex);

                name = name.Substring(0, 1) + " " + name.Substring(spaceIndex, name.Length - spaceIndex);
            }

            if ((bool)timecard.IsChecked)
            {
                //to create save dialog box
                SaveFileDialog sfd1 = new SaveFileDialog();
                sfd1.Filter           = "PDF(*.pdf)|*.pdf";
                sfd1.FilterIndex      = 1;
                sfd1.Title            = "save time card";
                sfd1.FileName         = name + "_TimeCard.pdf";
                sfd1.RestoreDirectory = true;
                sfd1.ShowDialog();

                string     full_path = sfd1.InitialDirectory + sfd1.FileName;
                FileStream fs        = new FileStream(full_path, FileMode.Create);

                PdfWriter          wri = PdfWriter.GetInstance(doc, fs);
                OneColHeaderFooter PageEventHandler = new OneColHeaderFooter();
                wri.PageEvent = PageEventHandler;
                iTextSharp.text.Rectangle pagesize = doc.PageSize;

                String missingPunches = " Missing Punches!!! ";

                if (main.openConn())
                {
                    string query = "USE crst_dash; \n";
                    query += "SELECT pin FROM a_staff WHERE first_name = \"" + firstName + "\"";
                    cmd    = new MySqlCommand(query, main.myconn);

                    try
                    {
                        int counter = 1;
                        dr = cmd.ExecuteReader();
                        while (dr.Read())
                        {
                            PageEventHandler.Header = name + "      " + dr[0] + "      Time Report      " + date1 + "      to      " + date2;
                        }

                        main.closeConn();

                        //turn date1 and date2 into strings
                        String date11 = DateTime.Parse(date1).ToString("yyyy/MM/dd");
                        String date21 = DateTime.Parse(date2).ToString("yyyy/MM/dd");

                        main.openConn();
                        query = "USE crst_dash; \n" +
                                "SELECT COUNT(id) FROM a_staff_time WHERE name = \"" + name
                                + "\" AND  time >= \"" + date11
                                + "\" AND time <= \"" + date21
                                + "\" GROUP BY YEAR(time), MONTH(time), DAY(time)";

                        cmd = new MySqlCommand(query, main.myconn);
                        dr  = cmd.ExecuteReader();
                        ArrayList myCount = new ArrayList();

                        while (dr.Read())
                        {
                            myCount.Add(dr[0]);
                        }

                        Object[] countArr = myCount.ToArray();
                        main.closeConn();

                        main.openConn();

                        //open document
                        doc.Open();
                        cb = wri.DirectContent;

                        query = "USE crst_dash; \n" +
                                "SELECT time, status FROM a_staff_time WHERE name = \"" + name
                                + "\" AND  time >= \"" + date11
                                + "\" AND time <= \"" + date21 + "\" ORDER BY time ASC;";

                        cmd = new MySqlCommand(query, main.myconn);
                        dr  = cmd.ExecuteReader();
                        //index to check my count arr;
                        int     dex       = 0;
                        int     endPage   = 1;
                        int     toTheTop  = 60;
                        Boolean addedDate = true;

                        DateTime time1  = new DateTime();
                        DateTime time2  = new DateTime();
                        DateTime sum    = new DateTime();
                        double   sumAll = 0.0;

                        cb.BeginText();

                        while (dr.Read() && (dex < countArr.Length))
                        {
                            cb.SetFontAndSize(bf, 10);
                            Console.WriteLine(dr[0] + " <dr0    dr1> " + dr[1] + " counter -> " + counter);
                            if (addedDate)
                            {
                                addedDate = false;
                                cb.SetTextMatrix(pagesize.GetLeft(40), pagesize.GetTop(toTheTop));
                                String theDate = Convert.ToDateTime(dr[0]).ToString("MM-dd-yyyy");
                                cb.ShowText("Date: " + theDate);
                                endPage  += 1;
                                toTheTop += 20;
                                if (checkEndPage(endPage))
                                {
                                    cb.EndText();
                                    doc.NewPage();
                                    endPage  = 1;
                                    toTheTop = 60;
                                    cb.BeginText();
                                }
                            }

                            if (Convert.ToInt32(countArr[dex]) <= 4 && Convert.ToInt32(countArr[dex]) > 2)
                            {
                                if (counter == Convert.ToInt32(countArr[dex]) && counter != 4)
                                {
                                    if (Convert.ToInt32(dr[1]) == 0)
                                    {
                                        time2 = Convert.ToDateTime(dr[0]);
                                        cb.SetTextMatrix(pagesize.GetLeft(60), pagesize.GetTop(toTheTop));
                                        String outString = "out: " + time2.ToString("HH:mm:ss");
                                        toTheTop += 20;
                                        cb.ShowText(outString);
                                        endPage += 1;

                                        if (checkEndPage(endPage))
                                        {
                                            cb.EndText();
                                            doc.NewPage();
                                            endPage  = 1;
                                            toTheTop = 60;
                                            cb.BeginText();
                                        }

                                        double min = time2.Subtract(time1).Minutes;
                                        min = min / 100;
                                        int hours = time2.Subtract(time1).Hours;
                                        sumAll += (hours + min);

                                        cb.SetTextMatrix(pagesize.GetLeft(60), pagesize.GetTop(toTheTop));
                                        String totString = "total hours: " + (hours + min);
                                        toTheTop += 20;
                                        cb.ShowText(totString);
                                        endPage += 1;

                                        if (checkEndPage(endPage))
                                        {
                                            cb.EndText();
                                            doc.NewPage();
                                            endPage  = 1;
                                            toTheTop = 60;
                                            cb.BeginText();
                                        }
                                    }
                                    else
                                    {
                                        Console.WriteLine("1 t1 --");
                                        time1 = Convert.ToDateTime(dr[0]);
                                        cb.SetTextMatrix(pagesize.GetLeft(60), pagesize.GetTop(toTheTop));
                                        String inString = "in: " + time1.ToString("HH:mm:ss");
                                        toTheTop += 20;
                                        cb.ShowText(inString);
                                        endPage += 1;
                                        if (checkEndPage(endPage))
                                        {
                                            cb.EndText();
                                            doc.NewPage();
                                            endPage  = 1;
                                            toTheTop = 60;
                                            cb.BeginText();
                                        }
                                    }

                                    Console.WriteLine("IN HERE");
                                    String totalFinal = "final total hours: " + sumAll;

                                    line(pagesize, toTheTop, false);
                                    toTheTop += 20;
                                    endPage  += 1;

                                    if (checkEndPage(endPage))
                                    {
                                        cb.EndText();
                                        doc.NewPage();
                                        endPage  = 1;
                                        toTheTop = 60;
                                        cb.BeginText();
                                    }

                                    //cb.BeginText();
                                    cb.SetTextMatrix(pagesize.GetLeft(60), pagesize.GetTop(toTheTop));
                                    cb.ShowText(missingPunches);
                                    toTheTop += 20;
                                    endPage  += 1;
                                    if (checkEndPage(endPage))
                                    {
                                        cb.EndText();
                                        doc.NewPage();
                                        endPage  = 1;
                                        toTheTop = 60;
                                        cb.BeginText();
                                    }

                                    cb.SetTextMatrix(pagesize.GetLeft(60), pagesize.GetTop(toTheTop));
                                    cb.ShowText(totalFinal);
                                    toTheTop += 20;
                                    endPage  += 1;
                                    if (checkEndPage(endPage))
                                    {
                                        cb.EndText();
                                        doc.NewPage();
                                        endPage  = 1;
                                        toTheTop = 60;
                                        cb.BeginText();
                                    }

                                    equalline(pagesize, toTheTop);
                                    toTheTop += 20;
                                    endPage  += 1;
                                    if (checkEndPage(endPage))
                                    {
                                        cb.EndText();
                                        doc.NewPage();
                                        endPage  = 1;
                                        toTheTop = 60;
                                        cb.BeginText();
                                    }

                                    counter   = 1;
                                    addedDate = true;
                                    sumAll    = 0.0;
                                    sum       = new DateTime();
                                    dex++;
                                    continue;
                                }

                                //check status
                                if (Convert.ToInt32(dr[1]) == 0)
                                {
                                    Console.WriteLine("0 t2");
                                    time2 = Convert.ToDateTime(dr[0]);
                                    String outString = "out: " + time2.ToString("HH:mm:ss");

                                    cb.SetTextMatrix(pagesize.GetLeft(60), pagesize.GetTop(toTheTop));
                                    cb.ShowText(outString);
                                    toTheTop += 20;
                                    endPage  += 1;

                                    if (checkEndPage(endPage))
                                    {
                                        cb.EndText();
                                        doc.NewPage();
                                        endPage  = 1;
                                        toTheTop = 60;
                                        cb.BeginText();
                                    }

                                    if (Convert.ToInt32(countArr[dex]) < 4 && counter == 1)
                                    {
                                        Console.WriteLine("c - 1 < 4");

                                        String totalHr = "total hours: 0";
                                        cb.SetTextMatrix(pagesize.GetLeft(60), pagesize.GetTop(toTheTop));
                                        cb.ShowText(totalHr);
                                        toTheTop += 20;
                                        endPage  += 1;

                                        if (checkEndPage(endPage))
                                        {
                                            cb.EndText();
                                            doc.NewPage();
                                            endPage  = 1;
                                            toTheTop = 60;
                                            cb.BeginText();
                                        }
                                        line(pagesize, toTheTop, false);
                                        toTheTop += 20;
                                        endPage  += 1;
                                        if (checkEndPage(endPage))
                                        {
                                            cb.EndText();
                                            doc.NewPage();
                                            endPage  = 1;
                                            toTheTop = 60;
                                            cb.BeginText();
                                        }
                                    }
                                    else
                                    {
                                        sum += time2.Subtract(time1);
                                        Console.WriteLine(time2 + "   " + time1);
                                        Console.WriteLine(time2.Subtract(time1));
                                        double min = time2.Subtract(time1).Minutes;
                                        min = min / 100;
                                        int hours = time2.Subtract(time1).Hours;
                                        sumAll += (hours + min);

                                        String totalHr = "total hours: " + (hours + min);

                                        cb.SetTextMatrix(pagesize.GetLeft(60), pagesize.GetTop(toTheTop));
                                        cb.ShowText(totalHr);
                                        toTheTop += 20;
                                        endPage  += 1;
                                        if (checkEndPage(endPage))
                                        {
                                            cb.EndText();
                                            doc.NewPage();
                                            endPage  = 1;
                                            toTheTop = 60;
                                            cb.BeginText();
                                        }
                                    }

                                    if (counter == 4)
                                    {
                                        Console.WriteLine("c - 4");
                                        String finalTotal = "final total hours: " + sumAll;

                                        line(pagesize, toTheTop, false);
                                        toTheTop += 20;
                                        endPage  += 1;

                                        if (checkEndPage(endPage))
                                        {
                                            cb.EndText();
                                            doc.NewPage();
                                            endPage  = 1;
                                            toTheTop = 60;
                                            cb.BeginText();
                                        }

                                        cb.SetTextMatrix(pagesize.GetLeft(60), pagesize.GetTop(toTheTop));
                                        cb.ShowText(finalTotal);
                                        toTheTop += 20;
                                        endPage  += 1;
                                        if (checkEndPage(endPage))
                                        {
                                            cb.EndText();
                                            doc.NewPage();
                                            endPage  = 1;
                                            toTheTop = 60;
                                            cb.BeginText();
                                        }

                                        equalline(pagesize, toTheTop);
                                        toTheTop += 20;
                                        endPage  += 1;

                                        if (checkEndPage(endPage))
                                        {
                                            cb.EndText();
                                            doc.NewPage();
                                            endPage  = 1;
                                            toTheTop = 60;
                                            cb.BeginText();
                                        }

                                        counter   = 0;
                                        addedDate = true;
                                        sumAll    = 0.0;
                                        sum       = new DateTime();
                                        dex++;
                                    }
                                    else if (counter == 2)
                                    {
                                        Console.WriteLine("c - 2");
                                        line(pagesize, toTheTop, false);
                                        toTheTop += 20;
                                        endPage  += 1;

                                        if (checkEndPage(endPage))
                                        {
                                            cb.EndText();
                                            doc.NewPage();
                                            endPage  = 1;
                                            toTheTop = 60;
                                            cb.BeginText();
                                        }
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("1 t1");
                                    time1 = Convert.ToDateTime(dr[0]);
                                    cb.SetTextMatrix(pagesize.GetLeft(60), pagesize.GetTop(toTheTop));
                                    String inString = "in: " + time1.ToString("HH:mm:ss");
                                    cb.ShowText(inString);
                                    toTheTop += 20;
                                    endPage  += 1;
                                    if (checkEndPage(endPage))
                                    {
                                        cb.EndText();
                                        doc.NewPage();
                                        endPage  = 1;
                                        toTheTop = 60;
                                        cb.BeginText();
                                    }
                                }

                                counter++;
                            }
                            else if (Convert.ToInt32(countArr[dex]) <= 2)
                            {
                                if (counter == Convert.ToInt32(countArr[dex]) && counter != 2)
                                {
                                    if (Convert.ToInt32(dr[1]) == 0)
                                    {
                                        Console.WriteLine("2 0 t2");
                                        time2 = (DateTime)dr[0];
                                        String outString = "out: " + time2.ToString("HH:mm:ss");
                                        String totalHrs  = "total hours: " + 0;
                                        cb.SetTextMatrix(pagesize.GetLeft(60), pagesize.GetTop(toTheTop));
                                        cb.ShowText(outString);
                                        toTheTop += 20;
                                        endPage  += 1;
                                        if (checkEndPage(endPage))
                                        {
                                            cb.EndText();
                                            doc.NewPage();
                                            endPage  = 1;
                                            toTheTop = 60;
                                            cb.BeginText();
                                        }

                                        cb.SetTextMatrix(pagesize.GetLeft(60), pagesize.GetTop(toTheTop));
                                        cb.ShowText(totalHrs);
                                        toTheTop += 20;
                                        endPage  += 1;
                                        if (checkEndPage(endPage))
                                        {
                                            cb.EndText();
                                            doc.NewPage();
                                            endPage  = 1;
                                            toTheTop = 60;
                                            cb.BeginText();
                                        }
                                    }
                                    else
                                    {
                                        Console.WriteLine("2 1 t1");
                                        time1 = (DateTime)dr[0];
                                        String inString = "in: " + time1.ToString("HH:mm:ss");
                                        cb.SetTextMatrix(pagesize.GetLeft(60), pagesize.GetTop(toTheTop));
                                        cb.ShowText(inString);
                                        toTheTop += 20;
                                        endPage  += 1;
                                        if (checkEndPage(endPage))
                                        {
                                            cb.EndText();
                                            doc.NewPage();
                                            endPage  = 1;
                                            toTheTop = 60;
                                            cb.BeginText();
                                        }
                                    }

                                    String finalTotHrs = "final total hours: " + sumAll;

                                    line(pagesize, toTheTop, false);
                                    toTheTop += 20;
                                    endPage  += 1;
                                    if (checkEndPage(endPage))
                                    {
                                        cb.EndText();
                                        doc.NewPage();
                                        endPage  = 1;
                                        toTheTop = 60;
                                        cb.BeginText();
                                    }

                                    cb.SetTextMatrix(pagesize.GetLeft(60), pagesize.GetTop(toTheTop));
                                    cb.ShowText(missingPunches);
                                    toTheTop += 20;
                                    endPage  += 1;
                                    if (checkEndPage(endPage))
                                    {
                                        cb.EndText();
                                        doc.NewPage();
                                        endPage  = 1;
                                        toTheTop = 60;
                                        cb.BeginText();
                                    }

                                    cb.SetTextMatrix(pagesize.GetLeft(60), pagesize.GetTop(toTheTop));
                                    cb.ShowText(finalTotHrs);
                                    toTheTop += 20;
                                    endPage  += 1;
                                    if (checkEndPage(endPage))
                                    {
                                        cb.EndText();
                                        doc.NewPage();
                                        endPage  = 1;
                                        toTheTop = 60;
                                        cb.BeginText();
                                    }

                                    equalline(pagesize, toTheTop);
                                    toTheTop += 20;
                                    endPage  += 1;
                                    if (checkEndPage(endPage))
                                    {
                                        cb.EndText();
                                        doc.NewPage();
                                        endPage  = 1;
                                        toTheTop = 60;
                                        cb.BeginText();
                                    }

                                    counter   = 1;
                                    addedDate = true;
                                    sumAll    = 0.0;
                                    sum       = new DateTime();
                                    dex++;
                                    continue;
                                }


                                if (Convert.ToInt32(dr[1]) == 0)
                                {
                                    Console.WriteLine("2 0 t2 -- ");
                                    time2 = (DateTime)dr[0];
                                    sum  += time2.Subtract(time1);

                                    double min = time2.Subtract(time1).Minutes;
                                    min = min / 100;
                                    int hours = time2.Subtract(time1).Hours;
                                    sumAll += (hours + min);

                                    String outString = "out: " + time2.ToString("HH:mm:ss");
                                    String totalHrs  = "total hours: " + (hours + min);
                                    cb.SetTextMatrix(pagesize.GetLeft(60), pagesize.GetTop(toTheTop));
                                    cb.ShowText(outString);
                                    toTheTop += 20;
                                    endPage  += 1;
                                    if (checkEndPage(endPage))
                                    {
                                        cb.EndText();
                                        doc.NewPage();
                                        endPage  = 1;
                                        toTheTop = 60;
                                        cb.BeginText();
                                    }

                                    cb.SetTextMatrix(pagesize.GetLeft(60), pagesize.GetTop(toTheTop));
                                    cb.ShowText(totalHrs);
                                    toTheTop += 20;
                                    endPage  += 1;
                                    if (checkEndPage(endPage))
                                    {
                                        cb.EndText();
                                        doc.NewPage();
                                        endPage  = 1;
                                        toTheTop = 60;
                                        cb.BeginText();
                                    }


                                    if (counter == 2)
                                    {
                                        Console.WriteLine("2 c - 2");
                                        String finalTotalHrs = "final total hours: " + sumAll;

                                        line(pagesize, toTheTop, false);

                                        toTheTop += 20;
                                        endPage  += 1;
                                        if (checkEndPage(endPage))
                                        {
                                            cb.EndText();
                                            doc.NewPage();
                                            endPage  = 1;
                                            toTheTop = 60;
                                            cb.BeginText();
                                        }

                                        cb.SetTextMatrix(pagesize.GetLeft(60), pagesize.GetTop(toTheTop));
                                        cb.ShowText(finalTotalHrs);
                                        toTheTop += 20;
                                        endPage  += 1;
                                        if (checkEndPage(endPage))
                                        {
                                            cb.EndText();
                                            doc.NewPage();
                                            endPage  = 1;
                                            toTheTop = 60;
                                            cb.BeginText();
                                        }

                                        equalline(pagesize, toTheTop);
                                        toTheTop += 20;
                                        endPage  += 1;
                                        if (checkEndPage(endPage))
                                        {
                                            cb.EndText();
                                            doc.NewPage();
                                            endPage  = 1;
                                            toTheTop = 60;
                                            cb.BeginText();
                                        }

                                        counter   = 0;
                                        addedDate = true;
                                        sumAll    = 0.0;
                                        sum       = new DateTime();
                                        dex++;
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("2 1 t1 -- ");
                                    time1 = (DateTime)dr[0];
                                    String inString = "in: " + time1.ToString("HH:mm:ss");
                                    cb.SetTextMatrix(pagesize.GetLeft(60), pagesize.GetTop(toTheTop));
                                    cb.ShowText(inString);
                                    toTheTop += 20;
                                    endPage  += 1;

                                    if (checkEndPage(endPage))
                                    {
                                        cb.EndText();
                                        doc.NewPage();
                                        endPage  = 1;
                                        toTheTop = 60;
                                        cb.BeginText();
                                    }
                                }

                                counter++;
                            }
                        }
                        cb.EndText();
                    }

                    catch (Exception ex)
                    {
                        Console.WriteLine("Error: " + ex);
                    }
                }
                doc.Close();
                main.closeConn();
                main.dialogHost.IsOpen = false;
                main.snackbar.MessageQueue.Enqueue("Pdf Created");
            }
            else if ((bool)summary.IsChecked)
            {
                //to check all people's hours
                //to create save dialog box
                SaveFileDialog sfd1 = new SaveFileDialog();
                sfd1.Filter      = "PDF(*.pdf)|*.pdf";
                sfd1.FilterIndex = 1;
                sfd1.Title       = "save summary";
                string[] splited_date1  = date1.Split('/');
                string   date1_no_slash = splited_date1[0] + "_" + splited_date1[1] + "_" + splited_date1[2];
                sfd1.FileName         = "Summary_for_week_of_" + date1_no_slash + ".pdf";
                sfd1.RestoreDirectory = true;
                sfd1.ShowDialog();

                string     full_path = sfd1.InitialDirectory + sfd1.FileName;
                FileStream fs        = new FileStream(full_path, FileMode.Create);

                PdfWriter          wri = PdfWriter.GetInstance(doc, fs);
                OneColHeaderFooter PageEventHandler = new OneColHeaderFooter();
                wri.PageEvent = PageEventHandler;
                iTextSharp.text.Rectangle pagesize = doc.PageSize;
                int fromTop = 60;
                int endPage = 1;

                if (main.openConn())
                {
                    PageEventHandler.Header = "Hours Summary Report for " + date1 + " to " + date2;
                    ArrayList names = new ArrayList();
                    string    query = "USE crst_dash; \n";
                    query += "SELECT first_name, last_name FROM a_staff";
                    cmd    = new MySqlCommand(query, main.myconn);

                    dr = cmd.ExecuteReader();

                    while (dr.Read())
                    {
                        String fn     = dr[0].ToString();
                        String myName = fn.Substring(0, 1) + " " + dr[1].ToString();

                        names.Add(myName);
                    }

                    //open document
                    doc.Open();
                    cb = wri.DirectContent;

                    Object[] nameArr = names.ToArray();
                    main.closeConn();
                    DateTime sevenDate = Convert.ToDateTime(date1).AddDays(7.0);

                    for (int i = 0; i < nameArr.Length; i++)
                    {
                        int    countDays = 0;
                        double seven     = 0.0;
                        double fourteen  = 0.0;

                        //to get pin of the staff using name
                        main.openConn();
                        query  = "USE crst_dash; \n";
                        query += "SELECT pin FROM a_staff_time WHERE name = \""
                                 + nameArr[i] + "\"";
                        cmd = new MySqlCommand(query, main.myconn);
                        dr  = cmd.ExecuteReader();
                        String pin = "";
                        while (dr.Read())
                        {
                            pin = dr[0].ToString();
                        }
                        main.closeConn();

                        //to get first name and last name from a_staff using pin
                        main.openConn();
                        query  = "USE crst_dash; \n";
                        query += "SELECT first_name, last_name FROM a_staff WHERE pin = \""
                                 + pin + "\"";
                        cmd = new MySqlCommand(query, main.myconn);
                        dr  = cmd.ExecuteReader();
                        String fullName = "";
                        while (dr.Read())
                        {
                            fullName = dr[0].ToString() + " " + dr[1].ToString();
                        }
                        main.closeConn();

                        //to get the department from a_staff using pin
                        main.openConn();
                        query  = "USE crst_dash; \n";
                        query += "SELECT department FROM a_staff WHERE pin = \""
                                 + pin + "\"";
                        cmd = new MySqlCommand(query, main.myconn);
                        dr  = cmd.ExecuteReader();
                        String dept = "";
                        while (dr.Read())
                        {
                            dept = dr[0].ToString();
                        }
                        main.closeConn();

                        //to count the dates between date1 and date2
                        main.openConn();
                        String date11 = DateTime.Parse(date1).ToString("yyyy/MM/dd");
                        String date21 = DateTime.Parse(date2).ToString("yyyy/MM/dd");
                        query = "USE crst_dash; \n" +
                                "SELECT COUNT(id) FROM a_staff_time WHERE name = \"" + nameArr[i]
                                + "\" AND  time >= \"" + date11
                                + "\" AND time <= \"" + date21
                                + "\" GROUP BY YEAR(time), MONTH(time), DAY(time)";
                        cmd = new MySqlCommand(query, main.myconn);
                        dr  = cmd.ExecuteReader();
                        ArrayList myCount = new ArrayList();

                        while (dr.Read())
                        {
                            myCount.Add(dr[0]);
                        }

                        Object[] countArr = myCount.ToArray();

                        main.closeConn();

                        //to get the time and status between date1 and date2
                        main.openConn();
                        query = "USE crst_dash; \n" +
                                "SELECT time, status FROM a_staff_time WHERE name = \"" + nameArr[i]
                                + "\" AND  time >= \"" + date11
                                + "\" AND time <= \"" + date21 + "\" ORDER BY time ASC;";


                        cmd = new MySqlCommand(query, main.myconn);
                        dr  = cmd.ExecuteReader();

                        //index to check my count arr;
                        int      dex     = 0;
                        int      counter = 1;
                        DateTime time1   = new DateTime();
                        DateTime time2   = new DateTime();
                        double   sumAll  = 0;

                        while (dr.Read() && (dex < countArr.Length))
                        {
                            if (Convert.ToInt32(countArr[dex]) <= 4 && Convert.ToInt32(countArr[dex]) > 2)
                            {
                                if (Convert.ToInt32(dr[1]) == 0)
                                {
                                    time2 = Convert.ToDateTime(dr[0]);
                                    double min   = time2.Subtract(time1).Minutes;
                                    int    hours = time2.Subtract(time1).Hours;
                                    min     = min / 100;
                                    sumAll += (hours + min);
                                    if (countDays <= 9)
                                    {
                                        seven = sumAll;
                                        Console.WriteLine(seven + " seven 4");
                                    }

                                    if (countDays >= 10)
                                    {
                                        fourteen += (hours + min);
                                    }

                                    countDays++;
                                }
                                else
                                {
                                    time1 = Convert.ToDateTime(dr[0]);
                                }
                            }
                            else if (Convert.ToInt32(countArr[dex]) <= 2)
                            {
                                if (Convert.ToInt32(dr[1]) == 0)
                                {
                                    time2 = Convert.ToDateTime(dr[0]);

                                    double min   = time2.Subtract(time1).Minutes;
                                    int    hours = time2.Subtract(time1).Hours;
                                    min     = min / 100;
                                    sumAll += (hours + min);

                                    if (countDays <= 9)
                                    {
                                        seven = sumAll;
                                        Console.WriteLine(seven + " seven 2");
                                    }

                                    if (countDays >= 10)
                                    {
                                        fourteen += (hours + min);
                                    }
                                    countDays++;
                                }
                                else
                                {
                                    time1 = Convert.ToDateTime(dr[0]);
                                }
                            }

                            counter++;
                        }

                        //so words don't go off of the page - add a new paghe to doc and reset endpage and fromTop
                        if (endPage == 35)
                        {
                            endPage = 1;
                            fromTop = 60;
                            doc.NewPage();
                        }

                        if (pin != "")
                        {
                            //name pin dept wages
                            cb.SetFontAndSize(bf, 12);
                            cb.BeginText();
                            cb.SetTextMatrix(pagesize.GetLeft(40), pagesize.GetTop(fromTop));
                            cb.ShowText(fullName);
                            cb.SetFontAndSize(bf, 10);
                            cb.SetTextMatrix(pagesize.GetLeft(200), pagesize.GetTop(fromTop));
                            cb.ShowText("Pin " + pin);
                            cb.SetTextMatrix(pagesize.GetLeft(300), pagesize.GetTop(fromTop));
                            cb.ShowText("Dept " + dept);
                            cb.SetTextMatrix(pagesize.GetLeft(400), pagesize.GetTop(fromTop));
                            cb.ShowText("Wages");
                            fromTop += 20;


                            //first week of pay period
                            cb.SetTextMatrix(pagesize.GetLeft(40), pagesize.GetTop(fromTop));
                            String firstWeek = "Week of " + DateTime.Parse(date1).ToString("yyyy/MM/dd");
                            cb.ShowText(firstWeek);
                            cb.SetTextMatrix(pagesize.GetLeft(200), pagesize.GetTop(fromTop));
                            cb.ShowText("Total: " + seven);
                            fromTop += 20;

                            //second week of pay period
                            cb.SetTextMatrix(pagesize.GetLeft(40), pagesize.GetTop(fromTop));
                            String secondWeek = "Week of " + sevenDate.ToString("yyyy/MM/dd");
                            cb.ShowText(secondWeek);
                            cb.SetTextMatrix(pagesize.GetLeft(200), pagesize.GetTop(fromTop));
                            cb.ShowText("Total: " + fourteen);

                            /*
                             * if (fourteen == 0.0 && (string.Compare(seven, "0.0") < 0))
                             * {
                             *  String secondWeek = "Week of " + sevenDate.ToString("yyyy/MM/dd");
                             *  cb.ShowText(secondWeek);
                             *  cb.SetTextMatrix(pagesize.GetLeft(200), pagesize.GetTop(fromTop));
                             *  cb.ShowText("Total: " + fourteen);
                             * }
                             * else
                             * {
                             *  String secondWeek = "Week of " + sevenDate.ToString("yyyy/MM/dd");
                             *  cb.ShowText(secondWeek);
                             *  cb.SetTextMatrix(pagesize.GetLeft(200), pagesize.GetTop(fromTop));
                             *  cb.ShowText("Total: " + sumAll);
                             * }*/

                            fromTop += 20;

                            //weekly total
                            cb.SetTextMatrix(pagesize.GetLeft(200), pagesize.GetTop(fromTop));
                            String total = "Weekly Total: " + sumAll;
                            cb.ShowText(total);
                            fromTop += 20;

                            line(pagesize, fromTop, true);

                            fromTop += 20;
                            endPage += 3;
                        }
                        main.closeConn();
                    }
                }

                main.closeConn();
                doc.Close();
                main.dialogHost.IsOpen = false;
                main.snackbar.MessageQueue.Enqueue("Pdf Created");
            }
            main.dialogHost.IsOpen = false;
        }
Exemplo n.º 15
0
 private static Rectangle GetSignatureLocation(Rectangle cropBox, PdfSignatureParameters parameters)
 {
     return new Rectangle(cropBox.GetLeft(parameters.SignatureLeftMargin), 
         cropBox.GetTop(parameters.SignatureYLocation + parameters.SignatureHeight), 
         cropBox.Width - parameters.SignatureRightMargin, 
         cropBox.GetTop(parameters.SignatureYLocation));
 }
Exemplo n.º 16
0
 /**
 * @see com.lowagie.text.pdf.PdfPageEvent#onGenericTag(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document, com.lowagie.text.Rectangle, java.lang.String)
 */
 public override void OnGenericTag(PdfWriter writer, Document document,
         Rectangle rect, String text) {
     rect.Bottom = rect.Bottom - 3;
     PdfFormField field;
     genericChunkFields.TryGetValue(text, out field);
     if (field == null) {
         TextField tf = new TextField(writer, new Rectangle(rect.GetLeft(padding), rect.GetBottom(padding), rect.GetRight(padding), rect.GetTop(padding)), text);
         tf.FontSize = 14;
         field = tf.GetTextField();
     }
     else {
         field.Put(PdfName.RECT,  new PdfRectangle(rect.GetLeft(padding), rect.GetBottom(padding), rect.GetRight(padding), rect.GetTop(padding)));
     }
     if (parent == null)
         writer.AddAnnotation(field);
     else
         parent.AddKid(field);
 }
Exemplo n.º 17
0
 /**
 * @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(com.lowagie.text.pdf.PdfPCell, com.lowagie.text.Rectangle, com.lowagie.text.pdf.PdfContentByte[])
 */
 virtual public void CellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] canvases) {
     if (cellField == null || (fieldWriter == null && parent == null)) throw new ArgumentException(MessageLocalization.GetComposedMessage("you.have.used.the.wrong.constructor.for.this.fieldpositioningevents.class"));
     cellField.Put(PdfName.RECT, new PdfRectangle(rect.GetLeft(padding), rect.GetBottom(padding), rect.GetRight(padding), rect.GetTop(padding)));
     if (parent == null)
         fieldWriter.AddAnnotation(cellField);
     else
         parent.AddKid(cellField);
 }
Exemplo n.º 18
0
 /**
 * @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(com.lowagie.text.pdf.PdfPCell, com.lowagie.text.Rectangle, com.lowagie.text.pdf.PdfContentByte[])
 */
 public void CellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] canvases)
 {
     if (cellField == null || (fieldWriter == null && parent == null)) throw new ArgumentException("You have used the wrong constructor for this FieldPositioningEvents class.");
     cellField.Put(PdfName.RECT, new PdfRectangle(rect.GetLeft(padding), rect.GetBottom(padding), rect.GetRight(padding), rect.GetTop(padding)));
     if (parent == null)
         fieldWriter.AddAnnotation(cellField);
     else
         parent.AddKid(cellField);
 }