Ejemplo n.º 1
0
        public void FooterSection()
        {
            HeaderFooter footer = Pdf.LastSection.Footers.Primary;

            Table table = footer.AddTable();

            table.AddColumn(footer.Section.PageWidth() / 2);
            table.AddColumn(footer.Section.PageWidth() / 2);
            Row row = table.AddRow();

            if (!string.IsNullOrEmpty(Invoice.Footer))
            {
                Paragraph paragraph = row.Cells[0].AddParagraph(Invoice.Footer, ParagraphAlignment.Left, "H2-8-Blue");
                Hyperlink link      = paragraph.AddHyperlink(Invoice.Footer, HyperlinkType.Web);
            }

            Paragraph info = row.Cells[1].AddParagraph();

            info.Format.Alignment = ParagraphAlignment.Right;
            info.Style            = "H2-8";
            info.AddText("Page ");
            info.AddPageField();
            info.AddText(" of ");
            info.AddNumPagesField();
        }
Ejemplo n.º 2
0
        public void FooterSection()
        {
            HeaderFooter footer = Pdf.LastSection.Footers.Primary;

            Table table = footer.AddTable();

            table.AddColumn(footer.Section.PageWidth());
            table.AddColumn(footer.Section.PageWidth() / 10);
            Row row = table.AddRow();

            if (Invoice.Company.HasLegalTextLines)
            {
                foreach (var line in Invoice.Company.LegalTextLines)
                {
                    row.Cells[0].AddParagraph(line, ParagraphAlignment.Center, "H2-9");
                }
            }

            row.Cells[1].AddParagraph();
            Paragraph info = row.Cells[1].AddParagraph();

            info.Format.Alignment = ParagraphAlignment.Right;
            info.Style            = "H2-9";
            info.AddPageField();
            info.AddText(" / ");
            info.AddNumPagesField();
        }
Ejemplo n.º 3
0
        public static void AddPrimaryFooter(ref Section sec, bool includedVirginBanner)
        {
            sec.PageSetup.DifferentFirstPageHeaderFooter = true;
            sec.PageSetup.StartingNumber = 1;

            HeaderFooter MainFooter  = sec.Footers.Primary;
            Table        FooterTable = MainFooter.AddTable();

            FooterTable.TopPadding = "1mm";
            Column c = FooterTable.AddColumn("90mm");

            c = FooterTable.AddColumn("90mm");
            c = FooterTable.AddColumn("10mm");

            Row       r   = null;
            Image     img = null;
            Hyperlink h   = null;
            Paragraph p   = null;

            r            = FooterTable.AddRow();
            r.TopPadding = "0.2mm";



            img                 = r.Cells[0].AddImage("C:\\images\\footer.jfif");
            img.Width           = "190mm";
            img.LockAspectRatio = true;

            HeaderFooter MainFooterPmy = sec.Footers.Primary;

            MainFooterPmy.AddImage("C:\\images\\footer.jfif");
        }
Ejemplo n.º 4
0
        private void HeaderSection()
        {
            HeaderFooter header = Pdf.LastSection.Headers.Primary;

            Table  table      = header.AddTable();
            double thirdWidth = Pdf.PageWidth() / 3;

            table.AddColumn(ParagraphAlignment.Left, thirdWidth * 2);
            table.AddColumn();

            Row row = table.AddRow();

            if (!string.IsNullOrEmpty(Invoice.Image))
            {
                Image image = row.Cells[0].AddImage(Invoice.Image);
                row.Cells[0].VerticalAlignment = VerticalAlignment.Center;

                image.Height = Invoice.ImageSize.Height;
                image.Width  = Invoice.ImageSize.Width;
            }

            TextFrame frame = row.Cells[1].AddTextFrame();

            Table subTable = frame.AddTable();

            subTable.AddColumn(thirdWidth / 2);
            subTable.AddColumn(thirdWidth / 2);

            row = subTable.AddRow();
            row.Cells[0].MergeRight = 1;
            row.Cells[0].AddParagraph(Invoice.Title, ParagraphAlignment.Right, "H1-20");

            row = subTable.AddRow();
            if (!String.IsNullOrEmpty(Invoice.OrderReference))
            {
                row.Cells[0].AddParagraph("COMMANDE N°:", ParagraphAlignment.Left, "H2-9B-Color");
                row.Cells[1].AddParagraph(Invoice.OrderReference, ParagraphAlignment.Right, "H2-9");
            }
            row.Cells[0].AddParagraph("EDITÉE LE:", ParagraphAlignment.Left, "H2-9B-Color");
            row.Cells[1].AddParagraph(Invoice.InvoiceDate.ToString("dd/MM/yyyy"), ParagraphAlignment.Right, "H2-9");

            if (Invoice.PayedDate != DateTime.MinValue)
            {
                row.Cells[0].AddParagraph("PAYÉE LE:", ParagraphAlignment.Left, "H2-9B-Color");
                row.Cells[1].AddParagraph(Invoice.PayedDate.ToString("dd/MM/yyyy"), ParagraphAlignment.Right, "H2-9");
            }
        }
Ejemplo n.º 5
0
        private void HeaderSection()
        {
            HeaderFooter header = Pdf.LastSection.Headers.Primary;

            Table  table      = header.AddTable();
            double thirdWidth = Pdf.PageWidth() / 3;

            table.AddColumn(ParagraphAlignment.Left, thirdWidth * 2);
            table.AddColumn();

            Row row = table.AddRow();

            if (!string.IsNullOrEmpty(Invoice.Image))
            {
                Image image = row.Cells[0].AddImage(Invoice.Image);
                row.Cells[0].VerticalAlignment = VerticalAlignment.Center;

                image.Height = Invoice.ImageSize.Height;
                image.Width  = Invoice.ImageSize.Width;
            }

            TextFrame frame = row.Cells[1].AddTextFrame();

            Table subTable = frame.AddTable();

            subTable.AddColumn(thirdWidth / 2);
            subTable.AddColumn(thirdWidth / 2);

            row = subTable.AddRow();
            row.Cells[0].MergeRight = 1;
            row.Cells[0].AddParagraph(Invoice.Title, ParagraphAlignment.Right, "H1-20");

            row = subTable.AddRow();
            row.Cells[0].AddParagraph("REFERENCE:", ParagraphAlignment.Left, "H2-9B-Color");
            row.Cells[1].AddParagraph(Invoice.Reference, ParagraphAlignment.Right, "H2-9");
            row.Cells[0].AddParagraph("INVOICE DATE:", ParagraphAlignment.Left, "H2-9B-Color");
            row.Cells[1].AddParagraph(Invoice.InvoiceDate.ToString("dd/MM/yyyy"), ParagraphAlignment.Right, "H2-9");
            row.Cells[0].AddParagraph("DUE DATE:", ParagraphAlignment.Left, "H2-9B-Color");
            row.Cells[1].AddParagraph(Invoice.DueDate.ToString("dd/MM/yyyy"), ParagraphAlignment.Right, "H2-9");
        }
Ejemplo n.º 6
0
        public static void AddNoFooter(ref Section sec)
        {
            sec.PageSetup.DifferentFirstPageHeaderFooter = true;
            sec.PageSetup.StartingNumber = 1;

            HeaderFooter MainFooter  = sec.Footers.FirstPage;
            Table        FooterTable = MainFooter.AddTable();

            FooterTable.TopPadding = "1mm";
            Column c = FooterTable.AddColumn("160mm");

            c = FooterTable.AddColumn("10mm");
            c = FooterTable.AddColumn("20mm");

            Row   r   = null;
            Image img = null;

            r = FooterTable.AddRow();
            r.Cells[0].MergeRight = 2;
            img        = r.Cells[0].AddImage("C:\\images\\transpix.gif");
            img.Width  = "190mm";
            img.Height = "1mm";

            r = FooterTable.AddRow();


            r.TopPadding        = "0.2mm";
            img                 = r.Cells[0].AddImage("C:\\images\\footerplain.jpg");
            img.Width           = "190mm"; //"45mm";
            img.Height          = "25mm";
            img.LockAspectRatio = true;


            HeaderFooter MainFooterPmy = sec.Footers.Primary;

            MainFooterPmy.AddImage("C:\\images\\transpix.gif");
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Render table into header or footer
        /// </summary>
        public void RenderInto(HeaderFooter headerFooter)
        {
            MigraDoc.DocumentObjectModel.Tables.Table table = headerFooter.AddTable();

            this.RenderComponents(table);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //Create a new word document and add new section
            Document doc = new Document();
            Section  sec = doc.AddSection();

            //Get header
            HeaderFooter header = doc.Sections[0].HeadersFooters.Header;

            //Add new paragraph on header and set HorizontalAlignment of the paragraph as left
            Paragraph paragraph = header.AddParagraph();

            paragraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Left;

            //Load an image for the paragraph
            DocPicture headerimage = paragraph.AppendPicture(Image.FromFile(@"..\..\..\..\..\..\Data\Word.png"));

            //Add a table of 4 rows and 2 columns
            Table table = header.AddTable();

            table.ResetCells(4, 2);

            //Set the position of the table to the right of the image
            table.TableFormat.WrapTextAround = true;
            table.TableFormat.Positioning.HorizPositionAbs = HorizontalPosition.Outside;
            table.TableFormat.Positioning.VertRelationTo   = VerticalRelation.Margin;
            table.TableFormat.Positioning.VertPosition     = 43;

            //Add contents for the table
            String[][] data =
            {
                new string[]  { "Spire.Doc.left",         "Spire XLS.right"      },
                new string[]  { "Spire.Presentatio.left", "Spire.PDF.right"      },
                new string[]  { "Spire.DataExport.left",  "Spire.PDFViewe.right" },
                new string [] { "Spire.DocViewer.left",   "Spire.BarCode.right"  }
            };

            for (int r = 0; r < 4; r++)
            {
                TableRow dataRow = table.Rows[r];
                for (int c = 0; c < 2; c++)
                {
                    if (c == 0)
                    {
                        Paragraph par = dataRow.Cells[c].AddParagraph();
                        par.AppendText(data[r][c]);
                        par.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Left;
                        dataRow.Cells[c].Width         = 180;
                    }
                    else
                    {
                        Paragraph par = dataRow.Cells[c].AddParagraph();
                        par.AppendText(data[r][c]);
                        par.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Right;
                        dataRow.Cells[c].Width         = 180;
                    }
                }
            }

            //Save and launch document
            string output = "SetOutsidePosition.docx";

            doc.SaveToFile(output, FileFormat.Docx);
            Viewer(output);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Default constructor for reports to set up generic report structures and title block
        /// </summary>
        public ReportBase()
        {
            #region // Set up report document and page setup ...
            // Create a new document
            document = new Document();

            // just in case we change something on the default page setup, lets clone it first
            document.DefaultPageSetup.Clone();

            // Add a section to the document
            mainSection = document.AddSection();

            // get references to the section and default page setup
            PageSetup psSection = mainSection.PageSetup;
            PageSetup psDefault = document.DefaultPageSetup;

            // set up margins for content
            psSection.PageWidth      = psDefault.PageWidth;
            psSection.PageHeight     = psDefault.PageHeight;
            psSection.HeaderDistance = TopMargin;
            psSection.FooterDistance = BottomMargin;
            psSection.LeftMargin     = LeftMargin;
            psSection.RightMargin    = RightMargin;
            psSection.TopMargin      = TitleBlockHeight + TopMargin + Unit.FromCentimeter(0.2);
            psSection.BottomMargin   = BottomMargin + FooterHeight;
            #endregion

            #region // draw title block ...
            // add a (4x6) table to the header for the title block
            HeaderFooter header = mainSection.Headers.Primary;
            headerTable = header.AddTable();
            headerTable.Format.Font.Size = TitleBlockFontSize;
            for (int i = 0; i < 4; i++)
            {
                headerTable.AddColumn();
            }
            for (int i = 0; i < 6; i++)
            {
                headerTable.AddRow();
            }

            // merge the columns for the top row and the row surrounding the content
            headerTable[0, 0].MergeRight = 3;
            headerTable[5, 0].MergeRight = 3;

            // set cell sizes
            headerTable.Columns.Width        = ColWidthLabels;
            headerTable.Columns[1].Width     =
                headerTable.Columns[3].Width = (psDefault.PageWidth - LeftMargin - RightMargin - 2 * ColWidthLabels) / 2;

            headerTable.Columns[0].Format.Font.Bold     =
                headerTable.Columns[2].Format.Font.Bold = true;

            headerTable.Rows[0].Height = TitleRowHeight;
            headerTable.Rows.Height    = (TitleBlockHeight - TitleRowHeight) / 4;
            headerTable.Rows[5].Height = psDefault.PageHeight
                                         - psSection.TopMargin
                                         - psSection.BottomMargin;

            // set borders for the cells
            //headerTable.Borders.Color = Colors.Gray;
            headerTable[0, 0].Borders.Top.Width        = 2;
            headerTable.Columns[0].Borders.Left.Width  = 2;
            headerTable.Columns[3].Borders.Right.Width = 2;
            headerTable[5, 0].Borders.Top.Width        = 2;
            headerTable[5, 0].Borders.Bottom.Width     = 2;
            headerTable[0, 0].Format.Alignment         = ParagraphAlignment.Center;
            headerTable[0, 0].Format.Font.Size         = TitleFontSize;
            #endregion

            #region // set some default header values ...
            headerTable[0, 0].AddParagraph().AddInfoField(MigraDoc.DocumentObjectModel.Fields.InfoFieldType.Title);

            #endregion

            #region // set up footer ...
            var FooterTable = mainSection.Footers.Primary.AddTable();
            FooterTable.Format.Font.Size = FooterFontSize;
            FooterTable.Format.Alignment = ParagraphAlignment.Center;
            FooterTable.AddColumn("1cm");
            FooterTable.AddColumn(psSection.PageWidth - Unit.FromCentimeter(6) - LeftMargin - RightMargin);
            FooterTable.AddColumn("5cm");
            FooterTable.AddRow();
            FooterTable[0, 0].AddParagraph().AddPageField();
            FooterTable[0, 1].AddParagraph().AddFormattedText("Generated using Cutting Plan Maker", TextFormat.Italic);
            FooterTable[0, 2].AddParagraph().AddFormattedText($"Printed {DateTime.Now.ToString("HH:mm, dd MMM yyyy")}", TextFormat.Italic);
            #endregion
        }
        // create the headers and footers
        void CreateHeadersAndFooters(Document doc, TestResult testResult)
        {
            // ok so heres the main title of the header, should be the battery name
            Section      section = doc.AddSection();
            HeaderFooter headers = section.Headers.Primary;
            Paragraph    para    = headers.AddParagraph(testResult.batteryName);

            para.Style             = "Heading2";
            para.Format.Font.Color = Colors.Black;
            para.Format.Alignment  = ParagraphAlignment.Center;

            // now to add the table so that its got 3 columns, this is just the column spacings
            Table table = headers.AddTable();

            table.Format.Alignment = ParagraphAlignment.Center;
            table.Borders.Visible  = false;
            Column col = table.AddColumn("5cm");

            col.Format.Alignment = ParagraphAlignment.Left;
            col = table.AddColumn("6cm");
            col.Format.Alignment = ParagraphAlignment.Center;
            col = table.AddColumn("5cm");
            col.Format.Alignment = ParagraphAlignment.Right;

            // now we have to add rows to these columns, but only going to populate the left and right, for the first row
            Row       row     = table.AddRow();
            Paragraph rowPara = row.Cells[0].AddParagraph("Battery Dataset Detail Report");

            rowPara.Format.Font.Color  = Colors.DarkBlue;
            rowPara.Format.Font.Size   = 11;
            rowPara.Format.Font.Bold   = true;
            rowPara.Format.Font.Italic = true;
            rowPara = row.Cells[2].AddParagraph("Install Date : " + GetDateString(testResult.installDate));
            rowPara.Format.Font.Color = Colors.Black;
            rowPara.Format.Font.Size  = 11;
            rowPara.Format.Font.Bold  = true;

            // now for the second row, using all three column cells, batt Tag, block type, Location
            row     = table.AddRow();
            rowPara = row.Cells[0].AddParagraph(testResult.fileName);
            rowPara.Format.Font.Size  = 11;
            rowPara.Format.Font.Color = Colors.Black;
            rowPara.Format.Font.Bold  = true;
            rowPara = row.Cells[1].AddParagraph(testResult.modelNumber);
            rowPara.Format.Font.Size  = 11;
            rowPara.Format.Font.Color = Colors.Black;
            rowPara.Format.Font.Bold  = true;
            rowPara = row.Cells[2].AddParagraph(testResult.location);
            rowPara.Format.Font.Size  = 11;
            rowPara.Format.Font.Color = Colors.Black;
            rowPara.Format.Font.Bold  = true;

            // now add a blank colored bar across page, cant mind what its called so
            para = headers.AddParagraph();
            para.Format.Alignment = ParagraphAlignment.Center;
            Border border = para.Format.Borders.Bottom;

            border.Width = 2;
            border.Color = Colors.DarkRed;

            table = headers.AddTable();
            headers.Format.Alignment = ParagraphAlignment.Center;
            table.Borders.Visible    = false;
            col = table.AddColumn("8cm");
            col.Format.Alignment = ParagraphAlignment.Left;
            col = table.AddColumn("8cm");
            col.Format.Alignment = ParagraphAlignment.Center;

            row     = table.AddRow();
            rowPara = row.Cells[0].AddParagraph("Readings Taken : " + testResult.dateFileCreated);
            rowPara = row.Cells[1].AddParagraph("Overall Float Voltage : " + testResult.overallVoltage + " V");
            // stick another line below everything in the header

            // now add a blank colored bar across page, cant mind what its called so
            para = headers.AddParagraph();
            para.Format.Alignment = ParagraphAlignment.Center;
            border       = para.Format.Borders.Top;
            border.Width = 2;
            border.Color = Colors.DarkRed;
        }