Exemplo n.º 1
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();
        }
Exemplo n.º 2
0
        private void AddDocumentFooter()
        {
            if (String.IsNullOrWhiteSpace(DocumentFooter) && ShowPageNumber == false)
            {
                return; // Don't add any footer
            }
            var section = Document.LastSection;

            var footer1 = new Paragraph();

            if (!String.IsNullOrWhiteSpace(DocumentFooter))
            {
                footer1.Style = StyleNames.Footer;
                footer1.AddText(DocumentFooter);

                if (ShowPageNumber)
                {
                    footer1.AddLineBreak();
                }
            }

            if (ShowPageNumber)
            {
                footer1.AddText("Page ");
                footer1.AddPageField();
                footer1.AddText(" of ");
                footer1.AddNumPagesField();
            }

            section.Footers.Primary.Add(footer1.Clone());
            section.Footers.FirstPage.Add(footer1.Clone());
        }
Exemplo n.º 3
0
            private static void CreateNewSection(ref Document workingDoc, string sectionHead)
            {
                workingDoc.AddSection();
                workingDoc.LastSection.PageSetup.TopMargin    = Unit.FromInch(.25);
                workingDoc.LastSection.PageSetup.BottomMargin = Unit.FromInch(.5);
                workingDoc.LastSection.PageSetup.LeftMargin   = Unit.FromInch(.25);
                workingDoc.LastSection.PageSetup.RightMargin  = Unit.FromInch(.25);

                workingDoc.LastSection.AddParagraph(sectionHead, "Heading1");
                if (_rowBreak != null && _rowBreak != "" && sectionHead != "")
                {
                    //workingDoc.LastSection.Headers.Primary.AddParagraph(sectionHead);
                    //workingDoc.LastSection.PageSetup.HeaderDistance = new Unit(.75, UnitType.Inch);
                    //workingDoc.LastSection.AddParagraph(sectionHead, "Heading1");
                    workingDoc.LastSection.Headers.Primary.AddParagraph(_rowBreak + ":" + sectionHead);
                }

                Unit myFooter = new Unit(.20, UnitType.Inch);

                workingDoc.LastSection.PageSetup.FooterDistance = myFooter;
                //workingDoc.DefaultPageSetup.FooterDistance = myFooter;
                Paragraph pFooter = new Paragraph();

                pFooter.AddText("Page ");
                pFooter.AddPageField();
                pFooter.AddText(" of ");
                pFooter.AddNumPagesField();
                workingDoc.LastSection.Footers.Primary.Add(pFooter);
            }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
0
        public static Document CreateDocument(string Propriedade, string Nome = "", string InscricaoEstadual = "")
        {
            Section  section;
            Document doc;

            doc     = new Document();
            section = doc.AddSection();
            section.PageSetup.OddAndEvenPagesHeaderFooter = true;

            section.AddParagraph("RELATÓRIO - " + Convert.ToString(DateTime.Now.Date)).Format.Alignment = ParagraphAlignment.Center;

            section.AddParagraph("Proprietário: " + Nome);
            section.AddParagraph("Inscrição Estadual: " + InscricaoEstadual);
            section.AddParagraph("Propriedade: " + Propriedade);
            section.AddParagraph();

            Paragraph paragraph = new Paragraph();

            paragraph.AddText("Página ");
            paragraph.AddPageField();
            paragraph.AddText(" de ");
            paragraph.AddNumPagesField();

            section.Footers.Primary.Add(paragraph);
            section.Footers.EvenPage.Add(paragraph.Clone());

            section.PageSetup.Orientation = Orientation.Landscape;

            DefineStyles(doc);

            return(doc);
        }
Exemplo n.º 6
0
        public Section CreateDocumentSection()
        {
            Section section = _document.AddSection();

            // Set section footer
            Paragraph paragraph = new Paragraph();

            paragraph.Format.Font.Size   = 6;
            paragraph.Format.Alignment   = ParagraphAlignment.Right;
            paragraph.Format.Font.Italic = false;
            paragraph.Format.Font.Color  = Colors.DarkGray;
            paragraph.AddText($"Powered by {AppConstants.AppTitle} {AppConstants.AppVersion}");
            paragraph.AddSpace(3);
            paragraph.AddText("|");
            paragraph.AddSpace(3);
            paragraph.AddText(Phrases.GlobalPage);
            paragraph.AddSpace(1);
            paragraph.AddPageField();
            paragraph.AddSpace(1);
            paragraph.AddText(Phrases.GlobalOf);
            paragraph.AddSpace(1);
            paragraph.AddNumPagesField();

            section.Footers.Primary.Add(paragraph);
            section.Footers.EvenPage.Add(paragraph.Clone());

            return(section);
        }
Exemplo n.º 7
0
        private void AddFooter(Section section)
        {
            //var footer = section.Footers.Primary.AddParagraph();
            //footer.Format.AddTabStop(Size.GetWidth(section), TabAlignment.Right);


            //footer.AddTab();
            //footer.AddText("Symphony Media -Linear");//Here need to print Client Short Name
            //footer.AddTab();
            //footer.AddText("Page ");
            //footer.AddPageField();
            //footer.AddText(" of ");
            //footer.AddNumPagesField();
            Paragraph leftFooter = section.Footers.Primary.AddParagraph();

            leftFooter.Format.Font.Size = 10;
            leftFooter.Format.Alignment = ParagraphAlignment.Right;
            leftFooter.AddText("Symphony Media -Linear");

            Paragraph rightFooter = section.Footers.Primary.AddParagraph();

            rightFooter.Format.Font.Size = 10;
            rightFooter.Format.Alignment = ParagraphAlignment.Center;
            rightFooter.AddText("Page ");
            rightFooter.AddPageField();
            rightFooter.AddText(" of ");
            rightFooter.AddNumPagesField();
        }
Exemplo n.º 8
0
        private MigraDoc.DocumentObjectModel.Document CreatePrintDocument(PrintDocument pd)
        {
            string text;

            MigraDoc.DocumentObjectModel.Document doc = new MigraDoc.DocumentObjectModel.Document();
            doc.DefaultPageSetup.PageWidth    = Unit.FromInch((double)pd.DefaultPageSettings.PaperSize.Width / 100);
            doc.DefaultPageSetup.PageHeight   = Unit.FromInch((double)pd.DefaultPageSettings.PaperSize.Height / 100);
            doc.DefaultPageSetup.TopMargin    = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Top / 100);
            doc.DefaultPageSetup.LeftMargin   = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Left / 100);
            doc.DefaultPageSetup.RightMargin  = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Right / 100);
            doc.DefaultPageSetup.BottomMargin = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Bottom / 100);
            MigraDoc.DocumentObjectModel.Section section = doc.AddSection();
            section.PageSetup.StartingNumber = 1;
            MigraDoc.DocumentObjectModel.Font headingFont = MigraDocHelper.CreateFont(13, true);
            MigraDoc.DocumentObjectModel.Font bodyFontx   = MigraDocHelper.CreateFont(9, false);
            MigraDoc.DocumentObjectModel.Font nameFontx   = MigraDocHelper.CreateFont(9, true);
            MigraDoc.DocumentObjectModel.Font totalFontx  = MigraDocHelper.CreateFont(9, true);
            Paragraph pageNumParag = new Paragraph();

            pageNumParag.AddText(Lan.g(this, "Page") + " ");
            pageNumParag.AddPageField();
            pageNumParag.AddText(" " + Lan.g(this, "of") + " ");
            pageNumParag.AddNumPagesField();
            section.Footers.Primary.Add(pageNumParag);
            Paragraph       par       = section.AddParagraph();
            ParagraphFormat parformat = new ParagraphFormat();

            parformat.Alignment = ParagraphAlignment.Center;
            parformat.Font      = MigraDocHelper.CreateFont(14, true);
            par.Format          = parformat;
            //Render the reconcile grid.
            par = section.AddParagraph();
            par.Format.Alignment = ParagraphAlignment.Center;
            par.AddFormattedText(Lan.g(this, "RECONCILE"), totalFontx);
            par.AddLineBreak();
            text = Accounts.GetAccount(ReconcileCur.AccountNum).Description.ToUpper();
            par.AddFormattedText(text, totalFontx);
            par.AddLineBreak();
            text = PrefC.GetString(PrefName.PracticeTitle);
            par.AddText(text);
            par.AddLineBreak();
            text = PrefC.GetString(PrefName.PracticePhone);
            if (text.Length == 10 && Application.CurrentCulture.Name == "en-US")
            {
                text = "(" + text.Substring(0, 3) + ")" + text.Substring(3, 3) + "-" + text.Substring(6);
            }
            par.AddText(text);
            par.AddLineBreak();
            par.AddText(MiscData.GetNowDateTime().ToShortDateString());
            par.AddLineBreak();
            par.AddText(Lan.g(this, "Reconcile Date") + ": " + PIn.Date(textDate.Text).ToShortDateString());
            par.AddLineBreak();
            par.AddText(labelStart.Text + ": " + PIn.Double(textStart.Text).ToString("n"));
            par.AddLineBreak();
            par.AddText(labelEnd.Text + ": " + PIn.Double(textEnd.Text).ToString("n"));
            MigraDocHelper.InsertSpacer(section, 10);
            MigraDocHelper.DrawGrid(section, gridMain);
            return(doc);
        }
Exemplo n.º 9
0
        private void showPageNumber()
        {
            Paragraph pageNumber = new Paragraph();

            pageNumber.AddText("Page ");
            pageNumber.AddPageField();
            pageNumber.AddText(" of ");
            pageNumber.AddNumPagesField();
            section.Footers.Primary.Add(pageNumber);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Helper method to set styles for page numbers in header/footer.
 /// Page numbers are always aligned to the right.
 /// </summary>
 /// <param name="style"></param>
 /// <param name="pagenumField"></param>
 private static void FormatPagenumField(Style style, Paragraph pagenumField)
 {
     pagenumField.Style             = style.Name;
     pagenumField.Format.Alignment  = ParagraphAlignment.Right;
     pagenumField.Format.Font.Color = Colors.Black;
     pagenumField.AddPageField();
     pagenumField.AddText(" (");
     pagenumField.AddNumPagesField();
     pagenumField.AddText(")");
 }
Exemplo n.º 11
0
        public DocBuilder AddPageNumber()
        {
            var paragraph = new Paragraph();

            paragraph.AddText("Page ");
            paragraph.AddPageField();
            paragraph.AddText(" of ");
            paragraph.AddNumPagesField();
            section.Footers.Primary.Add(paragraph);
            return(this);
        }
Exemplo n.º 12
0
        private void CriarRodape()
        {
            Paragraph rodapeHr = _document.Sections[0].Footers.Primary.AddParagraph();

            rodapeHr.Format.Borders.Top = new Border
            {
                Width = "1pt",
                Color = Colors.DarkGreen
            };

            rodapeHr.Format.Alignment = ParagraphAlignment.Right;
            rodapeHr.AddText("Página ");
            rodapeHr.AddPageField();
            rodapeHr.AddText(" de ");
            rodapeHr.AddNumPagesField();
        }
Exemplo n.º 13
0
        //  [UnitTestFunction]
        public static void TestFields()
        {
            Document doc = new Document();

            doc.Info.Author = "K.P.";
            Section   sec = doc.Sections.AddSection();
            Paragraph par = sec.AddParagraph();

            par.AddBookmark("myBookmark1");

            PageRefField prf = par.AddPageRefField("myBookmark1");

            prf.Format = "ALPHABETIC";

            PageField pf = par.AddPageField();

            pf.Format = "ROMAN";

            SectionField sf = par.AddSectionField();

            sf.Format = "roman";

            SectionPagesField spf = par.AddSectionPagesField();

            spf.Format = "roman";

            NumPagesField npf = par.AddNumPagesField();

            npf.Format = "alphabetic";

            InfoField inf = par.AddInfoField(InfoFieldType.Author);
            DateField df  = par.AddDateField("D");

            df = par.AddDateField("d");
            df = par.AddDateField("s");
            df = par.AddDateField("r");
            df = par.AddDateField("G");
            df = par.AddDateField("dddd dd.MM.yyyy");

            DocumentRenderer docRndrr = new DocumentRenderer();

            docRndrr.Render(doc, "RtfFields.txt", null);

            File.Copy("RtfFields.txt", "RtfFields.rtf", true);
            System.Diagnostics.Process.Start("RtfFields.txt");
        }
        private void createUsFooterSection(Table footerTable)
        {
            Row footerRow1 = footerTable.AddRow();

            footerTable.Style = "footerStyle";
            Paragraph addressParagraph = footerRow1.Cells[1].AddParagraph();

            addressParagraph.AddText("Machine Tool Technology, Inc., Registered Office: 7 Burroughs,");

            Row       footerRow2   = footerTable.AddRow();
            Paragraph addressPara2 = footerRow2.Cells[1].AddParagraph();

            addressPara2.AddText("Irvine, California, 92618, USA.");

            Row       footerRow3   = footerTable.AddRow();
            Paragraph addressPara3 = footerRow3.Cells[1].AddParagraph();

            addressPara3.AddText("Registered in California, USA. Entity Number C3844807");

            Row       footerRow4   = footerTable.AddRow();
            Paragraph addressPara4 = footerRow4.Cells[1].AddParagraph();

            addressPara4.AddText("Tel. (949) 697-9062 Web Address: www.mttinc.us.com");

            //Merge the first cell, to contain the logo
            footerRow1.Cells[0].MergeDown = 3;
            footerRow1.Cells[2].MergeDown = 3;

            Paragraph pageNumberParagraph = footerRow1.Cells[2].AddParagraph();

            pageNumberParagraph.AddPageField();
            pageNumberParagraph.AddText(" (");
            pageNumberParagraph.AddNumPagesField();
            pageNumberParagraph.AddText(")");

            footerRow1.Cells[2].Style = "Normal";

            Image imgFooterLogo = Service_Reader.Properties.Resources.MTTIncHeaderlogo;

            string imageFileName = imageToMigradocString(imgFooterLogo);
            var    mttIncFooter  = footerRow1.Cells[0].AddImage(imageFileName);

            mttIncFooter.Height = new Unit(1.2, UnitType.Centimeter);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Renders the element.
        /// </summary>
        /// <param name="pdfStyling">The PDF styling.</param>
        /// <param name="section">The section.</param>
        public void Render(IPdfStyling pdfStyling, Section section)
        {
            section.PageSetup.StartingNumber = 1;

            TextFrame frame = section.Footers.Primary.AddTextFrame();

            frame.Width     = new Unit(pdfStyling.MaxWidthInPoints);
            frame.Height    = new Unit(10);                   //TODO: Why?
            frame.MarginTop = pdfStyling.PageNumberMarginTop; //TODO: Why?
            //frame.MarginTop = new Unit(69.5);

            Paragraph paragraph = frame.AddParagraph();

            paragraph.Format.Alignment = pdfStyling.PageNumberAlignment;
            //paragraph.AddText("Page "); //TODO: Multilingual
            paragraph.AddPageField();
            paragraph.AddText(" / ");
            paragraph.AddNumPagesField();
            paragraph.SetStyle(PdfStyleNames.Paragraph.Small);
        }
Exemplo n.º 16
0
        public static void Fields(string outputFile)
        {
            Document  document = new Document();
            Section   section  = document.AddSection();
            Paragraph par      = section.AddParagraph();

            par.AddText("Section: ");
            par.AddSectionField().Format = "ALPHABETIC";
            par.AddLineBreak();

            par.AddText("SectionPages: ");
            par.AddSectionField().Format = "alphabetic";
            par.AddLineBreak();

            par.AddText("Page: ");
            par.AddPageField().Format = "ROMAN";
            par.AddLineBreak();

            par.AddText("NumPages: ");
            par.AddNumPagesField();
            par.AddLineBreak();

            par.AddText("Date: ");
            par.AddDateField();
            par.AddLineBreak();

            par.AddText("Bookmark: ");
            par.AddBookmark("Egal");
            par.AddLineBreak();

            par.AddText("PageRef: ");
            par.AddPageRefField("Egal");

            PdfDocumentRenderer printer = new PdfDocumentRenderer()
            {
                Document = document
            };

            printer.RenderDocument(CancellationToken.None);
            printer.PdfDocument.Save(outputFile);
        }
        private static void createUkFooterSection(Table footerTable)
        {
            Row footerRow1 = footerTable.AddRow();

            footerTable.Style = "footerStyle";
            Paragraph addressParagraph = footerRow1.Cells[1].AddParagraph();

            addressParagraph.AddText("Machine Tool Technologies Ltd, 1H Ribble Court, 1 Meadway");

            Row       footerRow2   = footerTable.AddRow();
            Paragraph addressPara2 = footerRow2.Cells[1].AddParagraph();

            addressPara2.AddText("Shuttleworth Mead Business Park, Padiham, Lancashire, BB12 7NG, UK");

            Row       footerRow3   = footerTable.AddRow();
            Paragraph addressPara3 = footerRow3.Cells[1].AddParagraph();

            addressPara3.AddText("Tel. +44 (0) 845 077 9345  Fax. +44 (0) 1282 779 615  Web Address: www.mtt.uk.com");

            //Merge the first cell, to contain the logo
            footerRow1.Cells[0].MergeDown = 2;
            footerRow1.Cells[2].MergeDown = 2;

            Paragraph pageNumberParagraph = footerRow1.Cells[2].AddParagraph();

            pageNumberParagraph.AddPageField();
            pageNumberParagraph.AddText(" (");
            pageNumberParagraph.AddNumPagesField();
            pageNumberParagraph.AddText(")");

            footerRow1.Cells[2].Style = "Normal";

            Image imgFooterLogo = Service_Reader.Properties.Resources.MTTFooterLogo;

            string imageFileName = imageToMigradocString(imgFooterLogo);

            footerRow1.Cells[0].AddImage(imageFileName);
        }
Exemplo n.º 18
0
        static void _addTmpText <T>(Paragraph paragraph, string template, ArrayToPdfScheme <T> scheme)
        {
            foreach (var part in template.Split(new[] { '{', '}' }, StringSplitOptions.RemoveEmptyEntries))
            {
                switch (part)
                {
                case "TITLE":
                    paragraph.AddText(scheme.Title ?? string.Empty);
                    break;

                case "PAGE":
                    paragraph.AddPageField();
                    break;

                case "PAGES":
                    paragraph.AddNumPagesField();
                    break;

                default:
                    paragraph.AddText(part);
                    break;
                }
            }
        }
Exemplo n.º 19
0
        Section CreatePage()
        {
            section = this.document.AddSection();
            section.PageSetup.TopMargin    = "4.8cm";
            section.PageSetup.BottomMargin = "4cm";
            //Header
            //Image
            Image image = section.Headers.Primary.AddImage(HttpContext.Current.Server.MapPath("~/Content/images/headerPicture.png"));

            image.Height                 = "3.5cm";
            image.LockAspectRatio        = true;
            image.Top                    = ShapePosition.Top;
            image.Left                   = ShapePosition.Center;
            image.RelativeVertical       = RelativeVertical.Page;
            image.RelativeHorizontal     = RelativeHorizontal.Page;
            image.WrapFormat.Style       = WrapStyle.None;
            image.WrapFormat.DistanceTop = "0.5cm";

            //Code
            TextFrame textFrame = section.Headers.Primary.AddTextFrame();

            textFrame.Width                    = document.DefaultPageSetup.PageWidth;
            textFrame.Left                     = ShapePosition.Right;
            textFrame.WrapFormat.Style         = WrapStyle.None;
            textFrame.RelativeVertical         = RelativeVertical.Page;
            textFrame.RelativeHorizontal       = RelativeHorizontal.Page;
            textFrame.WrapFormat.DistanceTop   = "3cm";
            textFrame.WrapFormat.DistanceRight = "3cm";

            Paragraph paragraph = textFrame.AddParagraph();

            paragraph.Format.Font.Size = "8pt";
            paragraph.Format.Font.Name = "Arial";
            paragraph.Format.Alignment = ParagraphAlignment.Right;
            paragraph.AddText(documentContent.quoteCode);

            //Title
            textFrame                        = section.Headers.Primary.AddTextFrame();
            textFrame.Width                  = document.DefaultPageSetup.PageWidth;
            textFrame.Left                   = ShapePosition.Center;
            textFrame.WrapFormat.Style       = WrapStyle.None;
            textFrame.RelativeVertical       = RelativeVertical.Page;
            textFrame.RelativeHorizontal     = RelativeHorizontal.Page;
            textFrame.WrapFormat.DistanceTop = "4cm";

            paragraph = textFrame.AddParagraph();
            paragraph.Format.Font.Bold = true;
            paragraph.Format.Font.Size = "10pt";
            paragraph.Format.Alignment = ParagraphAlignment.Center;
            paragraph.AddText(string.Format("COTIZACIÓN {0}", documentContent.title));

            //Footer
            //Break
            textFrame = section.Footers.Primary.AddTextFrame();
            textFrame.WrapFormat.Style          = WrapStyle.None;
            textFrame.RelativeVertical          = RelativeVertical.Page;
            textFrame.RelativeHorizontal        = RelativeHorizontal.Page;
            textFrame.WrapFormat.DistanceBottom = "-1cm";
            textFrame.WrapFormat.DistanceLeft   = "2cm";
            textFrame.Width = document.DefaultPageSetup.PageWidth;

            paragraph   = textFrame.AddParagraph();
            image       = paragraph.AddImage(HttpContext.Current.Server.MapPath("~/Content/images/footerPicture.png"));
            image.Width = "18cm";
            //Company
            paragraph = textFrame.AddParagraph();
            paragraph.Format.Font.Size = "8pt";
            paragraph.Format.Alignment = ParagraphAlignment.Left;
            paragraph.AddFormattedText("CONFIABILIDAD EN EXACTITUD Y PRECISIÓN S.A. DE C.V.", TextFormat.Bold);
            paragraph.AddLineBreak();
            //Address
            paragraph = textFrame.AddParagraph();
            paragraph.AddText("Av. Parque América #116 Col. Vista Hermosa, C.P. 62290 Cuernavaca, Morelos, RFC: CEP 1102219EW4");
            paragraph.AddLineBreak();
            paragraph.AddLineBreak();
            //Pages
            paragraph.AddText("Página ");
            paragraph.AddPageField();
            paragraph.AddText(" de ");
            paragraph.AddNumPagesField();
            return(section);
        }
Exemplo n.º 20
0
        void Pages()
        {
            //Document doc = new Document();
            Section sec = doc.AddSection();

            // // create a table
            var table = sec.AddTable();

            table.AddColumn("7cm");
            table.AddColumn("13cm");
            var row = table.AddRow();

            table.Rows.LeftIndent = "0.5cm";
            var image = row.Cells[0].AddImage("Resources/logo.png");

            image.Height = "19mm";
            var cell = row.Cells[1].AddParagraph("Energy Service Report\n");

            //cell.AddBookmark("Energy Service Report");
            //cell.Format.Font.Name = "SegoeUIGrass";
            cell.Format.Font.Size = 22;
            cell.Format.Font.Bold = true;

            cell.Format.Font.Color = MigraDoc.DocumentObjectModel.Color.Parse("#103058");
            cell.Format.SpaceAfter = "3mm";

            var cell2 = row.Cells[1].AddParagraph("Cordium: Real - time heat control");

            cell2.Format.Font.Size  = 18;
            cell2.Format.Font.Color = MigraDoc.DocumentObjectModel.Color.Parse("#02BBE6");

            Paragraph line = sec.AddParagraph();

            line.Format.Borders.Distance = "-3pt";
            line.Format.Borders.Bottom   = new Border()
            {
                Width = "2pt", Color = Colors.DarkGray
            };
            //line.Format.SpaceAfter = "2mm";

            Paragraph Period = sec.AddParagraph("Period: ", "Heading1");

            Period.Format.TabStops.ClearAll();
            Period.Format.TabStops.AddTabStop(Unit.FromMillimeter(176), MigraDoc.DocumentObjectModel.TabAlignment.Right);
            Period.AddTab();
            Period.Format.Alignment = ParagraphAlignment.Left;
            string DateMY = DateTime.Now.ToString("MMMM, yyyy", System.Globalization.CultureInfo.CreateSpecificCulture("en-US"));

            Period.AddFormattedText(DateMY).Color = MigraDoc.DocumentObjectModel.Color.Parse("#838383");

            Paragraph ProjectDetails = sec.AddParagraph("Project Details:", "Heading1");

            var cordium = sec.AddImage("Resources/cordium.png");

            cordium.Left  = ShapePosition.Center;
            cordium.Width = "17 cm";
            DotListAdd2(doc, "Project Manager: Frank Louwet",
                        "Location: Crutzestraat, Hasselt");


            //для списка с точкой
            //string[] items = "Project Manager: Frank Louwet |Location: Crutzestraat, Hasselt ".Split('|');
            //for (int idx = 0; idx < items.Length; ++idx)
            //{
            //    ListInfo listinfo = new ListInfo();
            //    listinfo.ContinuePreviousList = idx > 0;
            //    listinfo.ListType = ListType.BulletList1;
            //    cordium = sec.AddParagraph(items[idx]);
            //    cordium.Style = "MyBulletList";
            //    cordium.Format.ListInfo = listinfo;
            //}
            //void DotListAdd(Document doc, Paragraph par, string str)
            //{
            //    ListInfo listinfo = new ListInfo();
            //    listinfo.ContinuePreviousList = false;
            //    listinfo.ListType = ListType.BulletList1;
            //    par = sec.AddParagraph(str);
            //    par.Style = "MyBulletList";
            //    par.Format.ListInfo = listinfo;
            //}

            void DotListAdd2(Document doc, params string[] arrstr)
            {
                //string[] items = "Project Manager: Frank Louwet |Location: Crutzestraat, Hasselt ".Split('|');
                for (int idx = 0; idx < arrstr.Length; ++idx)
                {
                    sec.AddParagraph(arrstr[idx], "BulletList");
                }
            }

            //doc.Styles.AddStyle("Bulletlist", "Normal");
            //var style = Styles["BulletList"];
            //style.ParagraphFormat.RightIndent = 12;
            //style.ParagraphFormat.TabStops.ClearAll();
            //style.ParagraphFormat.TabStops.AddTabStop(Unit.FromCentimeter(2.5), TabAlignment.Left);
            //style.ParagraphFormat.LeftIndent = "2.5cm";
            //style.ParagraphFormat.FirstLineIndent = "-0.5cm";
            //style.ParagraphFormat.SpaceBefore = 0;
            //style.ParagraphFormat.SpaceAfter = 0;

            Paragraph ExecutiveSummary = sec.AddParagraph("Executive Summary:", "Heading1");

            Paragraph ContentExecutiveSummary = sec.AddParagraph("This month there were a total of 345 degree days", "Text");

            ContentExecutiveSummary.Format.SpaceBefore = "5mm";

            sec.AddParagraph("Phase 1 heating energy:", "Text");
            sec.AddParagraph("2196 kWh of gas consumed(0.32 kWh per apartment per degree day)", "BulletList");
            sec.AddParagraph("Phase 2 heating energy: ", "Text");
            DotListAdd2(doc, "14515 kWh of gas consumed(2.1 kWh per apartment per degree day)",
                        "3.5 kWh of electricity consumed(0.00051 kWh per apartment per degree day)");
            sec.AddParagraph("Phase 3 heating energy: ", "Text");
            DotListAdd2(doc, "17791 kWh of gas consumed (1.8 kWh per apartment per degree day)",
                        "650 kWh of electricity produced");


            Paragraph ProjectOverview = sec.AddParagraph("Project Overview:", "Heading1");

            Paragraph ContentProjectOverview = sec.AddParagraph("The advanced control strategy is implemented in a district " +
                                                                "heating system for social housing in Crutzestraat, Hasselt. The social housing is operated " +
                                                                "by Cordium, the operating manager for social housing in Flemish region. The project consists" +
                                                                " of three phases or buildings with 20, 20 and 28 apartments in each phase. Each building " +
                                                                "has its own central heating system with various technologies installed. Furthermore, " +
                                                                "central heating systems are interconnected by an internal heat transfer network. " +
                                                                "i.Leco developed the control strategy which sends hourly setpoints fo: maximum and " +
                                                                "minimum temperature setpoint in each building and/or distribution circuit, operation " +
                                                                "modes of installed technologies, and distribution state settings between building/heating " +
                                                                "systems.", "Text");

            ContentProjectOverview.Format.SpaceAfter = "-5 mm";



            doc.LastSection.AddPageBreak();

            //2
            Paragraph phase1 = sec.AddParagraph("Phase 1", "Heading1");

            phase1.Format.Borders.Bottom.Visible = false;
            sec.AddParagraph("Installed technologies:", "Text");
            sec.AddParagraph("Geothermal/water gas absorption heat pumps – 2 pcs", "BulletList");
            //Paragraph fig1 = sec.AddParagraph("","figure");
            var img1 = sec.AddImage("Resources/2.1.jpg");

            //img1.Height = "10cm";
            img1.Top             = "10mm";
            img1.LockAspectRatio = true;
            img1.Left            = ShapePosition.Center;
            sec.AddParagraph("\nFigure 1: Phase 1 Energy Diagram", "figure");

            sec.AddParagraph("This month 20 MWh of heating energy was provided to the phase 1 building by heat pumps." +
                             " Consumption of gas compared with previous months is shown below.", "Text2");

            var img2 = sec.AddImage("Resources/2.2.jpg");

            img2.Left = ShapePosition.Center;
            sec.AddParagraph("Figure 2: Phase 1 Energy Consumption monthly comparison", "figure");

            Paragraph fig3 = sec.AddParagraph("", "figure");

            fig3.AddImage("Resources/2.3.jpg");
            fig3.AddFormattedText("\nFigure 3: Phase 1 Control (" + DateMY + ")", "Text");
            sec.AddParagraph("The minimum return water temperature this month was 39.4 °C", "Text");

            doc.LastSection.AddPageBreak();

            Paragraph phase2 = sec.AddParagraph("Phase 2", "Heading1");

            phase2.Format.Borders.Bottom.Visible = false;
            sec.AddParagraph("Installed technologies:", "Text");
            DotListAdd2(doc, "Electrical air/water heat pump",
                        "Electrical geothermal/water heat pump",
                        "Geothermal / water gas absorption heat pump",
                        "Gas condensing boiler");


            Paragraph fig4 = sec.AddParagraph("", "figure");

            fig4.Format.SpaceBefore = "10mm";
            fig4.AddImage("Resources/4.1.jpg");
            fig4.AddFormattedText("\nFigure 4: Phase 2 Energy Diagram", "Text");
            sec.AddParagraph("The electrical and gas energy consumed by the " +
                             "installed technologies this month is shown below:", "Text");
            //Paragraph fig5 = sec.AddParagraph("", "figure");
            var img5 = sec.AddImage("Resources/4.2.jpg");

            img5.Left = ShapePosition.Center;

            sec.AddParagraph("Figure 5: Phase 2 Energy Consumption", "figure");
            sec.AddParagraph("This month 19.5 MWh of heating energy was provided to the phase 2 " +
                             "building by heat pumps and the gas boiler.Consumption of electricity " +
                             "and gas compared with previous months is shown below.", "Text");

            var img6 = sec.AddImage("Resources/5.1.jpg");

            img6.Left = ShapePosition.Center;
            sec.AddParagraph("Figure 6: Phase 2 Energy Consumption monthly comparison", "figure");
            var img7 = sec.AddImage("Resources/5.2.jpg");

            img7.Left = ShapePosition.Center;
            sec.AddParagraph("Figure 7: Phase 2 Control (" + DateMY + ")", "figure");
            sec.AddParagraph("The minimum return water temperature this month was 35.6 °C", "Text");

            doc.LastSection.AddPageBreak();
            Paragraph phase3 = sec.AddParagraph("Phase 3", "Heading1");

            phase3.Format.Borders.Bottom.Visible = false;

            sec.AddParagraph("Installed technologies:", "Text");
            DotListAdd2(doc, "Combined heat and power",
                        "Gas boilers – 3 pcs");
            var img8 = sec.AddImage("Resources/6.1.jpg");

            img8.Left = ShapePosition.Center;
            img8.Top  = "8mm";
            sec.AddParagraph("\nFigure 8: Phase 3 Energy Diagram", "figure");
            sec.AddParagraph("The gas energy consumed by the installed technologies this month is shown below:", "Text");

            var img9 = sec.AddImage("Resources/6.2.jpg");

            img9.Left = ShapePosition.Center;
            sec.AddParagraph("Figure 9: Phase 3 Energy Consumption", "figure");
            sec.AddParagraph("This month 29 MWh of heating energy was provided to the phase 3 building by gas boilers and the combined heat & " +
                             "power plant.Consumption of gas and electricity production compared with previous months is shown below.", "Text");
            //7
            var img10 = sec.AddImage("Resources/7.1.jpg");

            img10.Left = ShapePosition.Center;
            sec.AddParagraph("Figure 10: Phase 3 Energy Consumption/production monthly comparison", "figure");

            var img11 = sec.AddImage("Resources/7.2.jpg");

            img11.Left = ShapePosition.Center;
            sec.AddParagraph("Figure 11: Phase 3 Control (" + DateMY + ")", "figure");
            sec.AddParagraph("The minimum return water temperature this month was 45.9 °C", "Text");

            // Create footer
            Paragraph footer = sec.Footers.Primary.AddParagraph();

            footer.AddText("i.Leco © ");
            footer.AddDateField("dd/MM/yyyy");
            // Clear all existing tab stops, and add our calculated tab stop, on the right
            footer.Format.TabStops.ClearAll();
            footer.Format.TabStops.AddTabStop(Unit.FromMillimeter(178), MigraDoc.DocumentObjectModel.TabAlignment.Right);
            footer.AddTab();
            footer.AddPageField();
            footer.AddText("/");
            footer.AddNumPagesField();
        }
Exemplo n.º 21
0
        private void Estatisticas_Partida()
        {
            Document document = new Document();

            document.Info.Title   = DateTime.Now.ToString("dd-MM-yyyy") + "_" + eventoAtual["nome"].ToString() + "_" + duplaAtual["nomedupla"].ToString();
            document.Info.Subject = "Relatório da partida.";

            Style style = document.Styles["Normal"];

            style.Font.Name = "Helvetica";

            Section section = document.AddSection();

            Paragraph paragraph = new Paragraph();

            paragraph.Format.Alignment = ParagraphAlignment.Center;
            paragraph.AddText("Página ");
            paragraph.AddPageField();
            paragraph.AddText(" de ");
            paragraph.AddNumPagesField();

            section.Headers.Primary.Add(paragraph);

            Paragraph title = section.AddParagraph();

            title.Format.Alignment = ParagraphAlignment.Center;
            title.AddFormattedText(eventoAtual["nome"].ToString(), TextFormat.Bold);

            section.AddParagraph();

            title = section.AddParagraph();
            title.Format.Alignment = ParagraphAlignment.Center;

            title.AddFormattedText("Data: ", TextFormat.Bold);
            title.AddText(DateTime.Now.ToString("dd/MM/yyyy"));
            title.AddFormattedText("\t\tHora: ", TextFormat.Bold);
            title.AddText(DateTime.Now.ToString("HH:mm:ss"));
            title.AddFormattedText("\t\tCategoria: ", TextFormat.Bold);
            title.AddText(categoriaAtual["nome"].ToString());

            section.AddParagraph();

            #region tabela de cabeçalho
            //Tabela de Cabeçalho
            Table t = section.AddTable();
            t.Style            = "Normal";
            t.Borders.Width    = 0.25;
            t.Format.Font.Size = 10;
            t.Rows.Height      = 14;

            t.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Center;
            t.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Center;
            t.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Center;
            t.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Center;

            Row r1 = t.AddRow();

            r1.VerticalAlignment = VerticalAlignment.Center;

            r1.Cells[0].Format.Font.Color = Colors.Red;
            r1.Cells[0].AddParagraph("In: " + atleta1["apelido"].ToString());
            r1.Cells[1].AddParagraph("Out: " + atleta2["apelido"].ToString());
            r1.Cells[2].MergeRight = 1;
            r1.Cells[2].AddParagraph().AddFormattedText("Pontuação Total: " + string.Format("{0:0.00}", pontuacao));

            Row r2 = t.AddRow();

            r2.Cells[0].AddParagraph("Tempo de Jogo: " + label2.Text);
            r2.Cells[0].MergeRight = 1;
            r2.Cells[2].AddParagraph("Equilíbrio: " + string.Format("{0:0.00}", equilibrio));
            r2.Cells[3].AddParagraph("Pontos: " + string.Format("{0:0.00}", equilibrio));

            Row r3 = t.AddRow();

            r3.Cells[0].Format.Font.Color = Colors.Red;
            r3.Cells[0].AddParagraph("Ataques In: " + ataquesAtleta1);
            r3.Cells[1].AddParagraph("Ataques Out: " + ataquesAtleta2);
            r3.Cells[2].AddParagraph("Total de Ataques: " + ataquesTotal);
            r3.Cells[3].AddParagraph("Pontos: " + string.Format("{0:0.00}", pontosAtaques));

            Row r4 = t.AddRow();

            r4.Cells[0].Format.Font.Color = Colors.Red;
            r4.Cells[0].AddParagraph("Potência In: " + string.Format("{0:0.00}", potenciaAtleta1));
            r4.Cells[1].AddParagraph("Potência Out: " + string.Format("{0:0.00}", potenciaAtleta2));
            r4.Cells[2].AddParagraph("Potência Média: " + string.Format("{0:0.00}", potenciaTotalMedia));
            r4.Cells[3].AddParagraph("Pontos: " + string.Format("{0:0.00}", pontosPotencia));

            Row r5 = t.AddRow();

            r5.Cells[0].Format.Font.Color = Colors.Red;
            r5.Cells[0].AddParagraph("Nota Juiz In: " + notaJuizAtleta1);
            r5.Cells[1].AddParagraph("Nota Juiz Out: " + notaJuizAtleta2);
            r5.Cells[2].AddParagraph("Nota Juiz Total: " + (notaJuizAtleta1 + notaJuizAtleta2));
            r5.Cells[3].AddParagraph("Pontos: " + (notaJuizAtleta1 + notaJuizAtleta2));

            Row r6 = t.AddRow();

            r6.Cells[1].MergeRight = 1;
            r6.Cells[1].AddParagraph("Número de Sequências: " + sequencias);
            r6.Cells[3].AddParagraph("Pontos: " + pontosSequencias);

            section.AddParagraph();
            section.AddParagraph();

            #endregion

            #region tabela de registros
            //Tabela de registros
            t = section.AddTable();

            t.Style            = "Normal";
            t.Format.Font.Size = 10;
            t.Rows.Height      = 14;

            t.AddColumn("5.33cm").Format.Alignment = ParagraphAlignment.Center;
            t.AddColumn("5.33cm").Format.Alignment = ParagraphAlignment.Center;
            t.AddColumn("5.33cm").Format.Alignment = ParagraphAlignment.Center;

            Row   r  = t.AddRow();
            Table t1 = r.Cells[0].AddTextFrame().AddTable();
            Table t2 = r.Cells[1].AddTextFrame().AddTable();
            Table t3 = r.Cells[2].AddTextFrame().AddTable();

            Table[] tables = new Table[3] {
                t1, t2, t3
            };

            foreach (Table tab in tables)
            {
                tab.Borders.Width = 0.25;

                tab.AddColumn("1.77cm").Format.Alignment = ParagraphAlignment.Center;
                tab.AddColumn("1.77cm").Format.Alignment = ParagraphAlignment.Center;
                tab.AddColumn("1.77cm").Format.Alignment = ParagraphAlignment.Center;

                r = tab.AddRow();
                r.VerticalAlignment = VerticalAlignment.Center;

                r.Cells[0].AddParagraph("Tempo");
                r.Cells[1].AddParagraph("In/Out");
                r.Cells[2].AddParagraph("Km/h");
            }

            int  start         = 0;
            int  i             = 0;
            int  pagelimit     = 44;
            int  numberofpages = 0;
            bool newpage       = false;

            foreach (SpeedRecord s in registrosRadar)
            {
                if (i != 0 && i % pagelimit == 0)
                {
                    start++; newpage = true;
                }

                if (start != 0 && start % 3 == 0 && newpage == true)
                {
                    numberofpages++;
                    pagelimit = 55;
                    i         = (pagelimit * numberofpages);
                    newpage   = false;
                    section.AddPageBreak();

                    t = section.AddTable();

                    t.Style            = "Normal";
                    t.Format.Font.Size = 10;
                    t.Rows.Height      = 14;

                    t.AddColumn("5.33cm").Format.Alignment = ParagraphAlignment.Center;
                    t.AddColumn("5.33cm").Format.Alignment = ParagraphAlignment.Center;
                    t.AddColumn("5.33cm").Format.Alignment = ParagraphAlignment.Center;

                    r  = t.AddRow();
                    t1 = r.Cells[0].AddTextFrame().AddTable();
                    t2 = r.Cells[1].AddTextFrame().AddTable();
                    t3 = r.Cells[2].AddTextFrame().AddTable();

                    tables[0] = t1; tables[1] = t2; tables[2] = t3;

                    foreach (Table tab in tables)
                    {
                        tab.Borders.Width = 0.25;

                        tab.AddColumn("1.77cm").Format.Alignment = ParagraphAlignment.Center;
                        tab.AddColumn("1.77cm").Format.Alignment = ParagraphAlignment.Center;
                        tab.AddColumn("1.77cm").Format.Alignment = ParagraphAlignment.Center;

                        r = tab.AddRow();
                        r.VerticalAlignment = VerticalAlignment.Center;

                        r.Cells[0].AddParagraph("Tempo");
                        r.Cells[1].AddParagraph("In/Out");
                        r.Cells[2].AddParagraph("Km/h");
                    }
                }

                Row x = tables[start % 3].AddRow();

                if (s.IdEvento == -1)
                {
                    x.Cells[0].AddParagraph("---");
                    x.Cells[1].AddParagraph("---");
                    x.Cells[2].AddParagraph("---");
                }
                else
                {
                    if (s.Direcao == 0)
                    {
                        x.Cells[0].Format.Font.Color = Colors.Red;
                        x.Cells[1].Format.Font.Color = Colors.Red;
                        x.Cells[2].Format.Font.Color = Colors.Red;
                        x.Cells[1].AddParagraph("In");
                    }
                    else
                    {
                        x.Cells[1].AddParagraph("Out");
                    }

                    x.Cells[0].AddParagraph(new DateTime(s.Ticks).ToString("mm:ss.ff"));
                    x.Cells[2].AddParagraph(s.Velocidade.ToString());
                }

                i++;
            }

            #endregion

            //table.SetEdge(0, 0, 6, 2, Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 0.75, MigraDoc.DocumentObjectModel.Color.Empty);

            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer();
            pdfRenderer.Document = document;
            pdfRenderer.RenderDocument();

            string fileName = "relatorios\\" + document.Info.Title + ".pdf";

            System.IO.Directory.CreateDirectory("relatorios");

            pdfRenderer.PdfDocument.Save(fileName);
            Process.Start(fileName);
        }
Exemplo n.º 22
0
        public virtual ActionResult RunReportToPdf(ReportParameters parms)
        {
            using (var db = NewDbContext())
            {
                IDbCommand cmd;
                double     fontSize = 9;

                try
                {
                    cmd = ReportCommand(parms);
                }
                catch (Exception ex)
                {
                    throw;
                }
                db.Database.Connection.Open();
                cmd.Connection = (IDbConnection)db.Database.Connection;

                PdfDocument pdfDocument = new PdfDocument();
                pdfDocument.Info.Title    = parms.ReportName;
                pdfDocument.Info.Author   = User.Identity.GetUserName();
                pdfDocument.Info.Subject  = parms.ReportDescription;
                pdfDocument.Info.Keywords = "";
                PdfPage page = pdfDocument.AddPage();
                page.Size = PdfSharp.PageSize.Letter;

                Document doc = new Document();
                Section  sec = doc.AddSection();
                sec.PageSetup.PageFormat     = PageFormat.Letter;
                sec.PageSetup.StartingNumber = 1;
                sec.PageSetup.RightMargin    = ".25in";
                sec.PageSetup.LeftMargin     = ".25in";
                sec.PageSetup.TopMargin      = ".75in";
                sec.PageSetup.BottomMargin   = ".25in";
                // 72 units per inch
                Style style = doc.Styles["Normal"];
                style.Font.Name           = "Verdana";
                page.Orientation          = (parms.PdfOrientation == "L") ? PdfSharp.PageOrientation.Landscape : PdfSharp.PageOrientation.Portrait;
                sec.PageSetup.Orientation = (parms.PdfOrientation == "L") ? Orientation.Landscape : Orientation.Portrait;

                double[] columnWidth = CalculateColumnWidths(parms, cmd, page, fontSize);
                double   availWidth  = page.Width.Point - sec.PageSetup.RightMargin.Point - sec.PageSetup.LeftMargin.Point - columnWidth.Length * 4;

                if (columnWidth.Sum() > availWidth)
                {
                    //page.Orientation = PdfSharp.PageOrientation.Landscape;
                    //sec.PageSetup.Orientation = Orientation.Landscape;
                    availWidth = page.Width.Point - sec.PageSetup.RightMargin.Point - sec.PageSetup.LeftMargin.Point - columnWidth.Length * 4;
                    while (columnWidth.Sum() > availWidth && fontSize > 5)
                    {
                        fontSize    = fontSize - 1;
                        columnWidth = CalculateColumnWidths(parms, cmd, page, fontSize);
                    }
                }
                var blankCol = Array.FindIndex(parms.ColumnNames, c => c.Equals("blank"));
                if (blankCol >= 0)
                {
                    double unused = availWidth - columnWidth.Sum();
                    columnWidth[blankCol] += unused;
                }

                var titleFont = new MigraDoc.DocumentObjectModel.Font("Verdana", 15);
                titleFont.Bold = true;
                var font = new MigraDoc.DocumentObjectModel.Font("Verdana", fontSize);

                var frame = sec.Headers.Primary.AddTextFrame();
                frame.Width            = page.Width.Point - sec.PageSetup.RightMargin.Point - sec.PageSetup.LeftMargin.Point;
                frame.Top              = ".25in";
                frame.Left             = 0;
                frame.RelativeVertical = MigraDoc.DocumentObjectModel.Shapes.RelativeVertical.Page;

                Paragraph paragraph = frame.AddParagraph();
                paragraph.Format.Font      = titleFont;
                paragraph.Format.Alignment = ParagraphAlignment.Center;
                paragraph.AddText(parms.ReportName);
                paragraph                  = frame.AddParagraph();
                paragraph.Format.Font      = font;
                paragraph.Format.Alignment = ParagraphAlignment.Center;
                paragraph.AddText(parms.ReportDescription);

                frame                      = sec.Headers.Primary.AddTextFrame();
                frame.Height               = ".2in";
                frame.Width                = "1.5in";
                frame.Top                  = ".30in";
                frame.Left                 = (page.Width.Point - sec.PageSetup.LeftMargin.Point - sec.PageSetup.RightMargin.Point - frame.Width.Point);
                frame.RelativeVertical     = MigraDoc.DocumentObjectModel.Shapes.RelativeVertical.Page;
                paragraph                  = frame.AddParagraph();
                paragraph.Format.Font      = font.Clone();
                paragraph.Format.Alignment = ParagraphAlignment.Right;
                paragraph.AddText("Page ");
                paragraph.AddPageField();
                paragraph.AddText(" of ");
                paragraph.AddNumPagesField();

                Table table = sec.AddTable();
                table.Style               = "Table";
                table.Borders.Color       = MigraDoc.DocumentObjectModel.Colors.DarkGray;
                table.Borders.Width       = 0.25;
                table.Borders.Left.Width  = 0.25;
                table.Borders.Right.Width = 0.25;
                table.Rows.LeftIndent     = 0;
                table.Rows.Alignment      = RowAlignment.Center;
                table.Format.Font         = new MigraDoc.DocumentObjectModel.Font("Verdana", fontSize);
                for (int x = 0; x < parms.ColumnNames.Length; x++)
                {
                    PdfTableColumnAdd(table, columnWidth[x], parms.ColumnNames[x]);
                }

                Row row = table.AddRow();
                row.HeadingFormat    = true;
                row.Format.Font.Bold = true;
                row.Shading.Color    = MigraDoc.DocumentObjectModel.Colors.LightGray;

                for (int x = 0; x < parms.ColumnNames.Length; x++)
                {
                    switch (parms.ColumnNames[x])
                    {
                    default:
                        row.Cells[x].AddParagraph(parms.ColumnHeadings[x]);
                        break;
                    }
                }

                using (var reader = cmd.ExecuteReader())
                {
                    int rowCnt = 0;
                    while (reader.Read())
                    {
                        try
                        {
                            rowCnt++;
                            row = table.AddRow();
                            for (int i = 0; i < parms.ColumnNames.Length; i++)
                            {
                                switch (reader[i].GetType().Name)
                                {
                                case "Boolean":
                                    row.Cells[i].AddParagraph(BoolToString((bool)reader[i]));
                                    break;

                                case "DateTime":
                                    row.Cells[i].AddParagraph(Zpm.FormatDate(reader[i]));
                                    break;

                                default:
                                    row.Cells[i].AddParagraph(reader[i].ToString());
                                    break;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            throw;
                        }
                    }
                }

                PdfDocumentRenderer renderer = new PdfDocumentRenderer(true);
                renderer.Document = doc;
                renderer.RenderDocument();

                string reportHandle = Guid.NewGuid().ToString();
                using (MemoryStream ms = new MemoryStream())
                {
                    renderer.PdfDocument.Save(ms);
                    TempData[reportHandle] = ms.ToArray();
                }
                return(Json(reportHandle));
            }
        }
        /// <summary>
        /// Creates the static parts of the invoice.
        /// </summary>
        private void OrderForm_CreatePage()
        {
            // Each MigraDoc document needs at least one section.
            Section section = this.document.AddSection();
            var     with_2  = section.PageSetup;

            //.HeaderDistance = "1cm"
            with_2.TopMargin = "4,5cm";

            with_2.BottomMargin   = "3,0cm";
            with_2.FooterDistance = "0,3cm";
            // Create footer


            // Put a logo in the header
            Image image = section.Headers.Primary.AddImage(Logo);

            image.Height             = "2.5cm";
            image.LockAspectRatio    = true;
            image.RelativeVertical   = RelativeVertical.Line;
            image.RelativeHorizontal = RelativeHorizontal.Margin;
            image.Top              = ShapePosition.Top;
            image.Left             = ShapePosition.Right;
            image.WrapFormat.Style = WrapStyle.Through;

            // Create the text frame for the address
            //section.Headers.Primary.AddParagraph()
            this.addressFrame      = section.Headers.Primary.AddTextFrame(); //AddParagraph() 'section.AddTextFrame()
            this.addressFrame.Top  = "3.0cm";
            this.addressFrame.Left = ShapePosition.Left;
            //.Height = "3.0cm"
            this.addressFrame.Width = "7.0cm";
            this.addressFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.addressFrame.RelativeVertical   = RelativeVertical.Page;

            // Create the text frame for the address
            //section.Headers.Primary.AddParagraph()
            this.deleveryFrame       = section.Headers.Primary.AddTextFrame(); //AddParagraph() 'section.AddTextFrame()
            this.deleveryFrame.Top   = "2.0cm";
            this.deleveryFrame.Left  = "7.00cm";                               //ShapePosition.Left
            this.deleveryFrame.Width = "5.0cm";
            //.Height = "3.0cm"
            this.deleveryFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.deleveryFrame.RelativeVertical   = RelativeVertical.Page;


            // Create footer
            Paragraph paragraph = section.Footers.Primary.AddParagraph();
            var       with_7    = paragraph.Format;

            with_7.SpaceBefore         = "1cm";
            with_7.Font.Size           = 7;
            with_7.Borders.Color       = RescueTekniq.Doc.OrderForm_Dk.TableBorder;
            with_7.Borders.Width       = 0.25;
            with_7.Borders.Left.Width  = 0.5;
            with_7.Borders.Right.Width = 0.5;
            with_7.Alignment           = ParagraphAlignment.Center;
            paragraph.AddText(Company.name); //("Heart2Start ApS")
            paragraph.AddText(" · ");

            paragraph.AddText(Company.adresse); //("Gefionsvej 8")

            paragraph.AddText(" · ");
            paragraph.AddText(Company.zipcode); //("3400")
            paragraph.AddText(" ");
            paragraph.AddText(Company.city);    //("Hillerød")
            if (this.Invoice.Virksomhed.LandekodeID != 45)
            {
                paragraph.AddText(" · ");
                paragraph.AddText(Company.country); //("Denmark")
            }
            paragraph.AddText(" · ");
            paragraph.AddText("CVR.nr. ");
            paragraph.AddText(Company.vatno); //("32446329")
            paragraph.AddText(" · ");
            if (this.Invoice.Virksomhed.LandekodeID != 45)
            {
                paragraph.AddText("Pho. ");
                paragraph.AddText(Company.int_phone); //("+45 48212879")
            }
            else
            {
                paragraph.AddText("Tlf. ");
                paragraph.AddText(Company.phone); //("48212879")
            }
            paragraph.AddText(" · ");
            //.AddText("www.RescueTekniq.dk")
            Hyperlink link = paragraph.AddHyperlink(string.Format("http://{0}", Company.link), HyperlinkType.Web);

            link.AddFormattedText(Company.link); //("www.RescueTekniq.dk")
            //.AddHyperlink("www.RescueTekniq.dk", HyperlinkType.Web)

            var with_8 = section.Footers.Primary.AddParagraph();
            var with_9 = with_8.Format;

            with_9.Font.Size = 4;
            with_9.Alignment = ParagraphAlignment.Center;
            with_8.AddLineBreak();
            with_8.AddLineBreak();
            with_8.AddText("- " + EANtitle + "Faktura nr. " + Invoice.ID.ToString());
            if (IsCopy)
            {
                with_8.AddText(" kopi");
            }
            with_8.AddText(" - side ");
            with_8.AddPageField();
            with_8.AddText(" af ");
            with_8.AddNumPagesField();
            with_8.AddText(" - ");

            // Create the text frame for the address
            this.headerFrame                    = section.AddTextFrame();
            this.headerFrame.Height             = "2.0cm";
            this.headerFrame.Width              = "5.5cm";
            this.headerFrame.Left               = ShapePosition.Right;
            this.headerFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.headerFrame.Top                = "4.5cm";
            this.headerFrame.RelativeVertical   = RelativeVertical.Page;
            // Add the print date field
            paragraph = this.headerFrame.AddParagraph();
            string Cvrnr = Company.vatno; //ConfigurationManager.AppSettings("company.vatno")

            // <add key="company.vatno" value="32446329" />

            paragraph.Style = "Reference";
            //.Format.Alignment = ParagraphAlignment.Right
            paragraph.AddFormattedText(EANtitle + "Følgebrev nr. " + Invoice.ID.ToString(), TextFormat.Bold);
            paragraph.AddLineBreak();

            paragraph.AddText(Company.city); //("Hillerød, ")
            paragraph.AddLineBreak();
            paragraph.AddText("dato: ");
            paragraph.AddText(Invoice.InvoiceDate.ToString("dd-MM-yyyy"));
            //.AddDateField("dd. MMM yyyy")
            paragraph.AddLineBreak();

            paragraph.AddText("CVR: ");
            paragraph.AddFormattedText(Cvrnr, TextFormat.Bold);
            paragraph.AddLineBreak();

            paragraph.AddText(this.Invoice.RettetAf.ToUpper());
            paragraph.AddText("/");
            if (this.Invoice.ResponsibleName.Trim() != "")
            {
                paragraph.AddText(this.Invoice.ResponsibleName.ToUpper());
            }
            paragraph.AddLineBreak();

            paragraph.AddLineBreak();

            paragraph.AddText("Side ");
            paragraph.AddPageField();
            paragraph.AddText(" af ");
            paragraph.AddNumPagesField();


            // Add the print date field
            paragraph = section.AddParagraph();
            paragraph.Format.SpaceBefore = "3cm";
            paragraph.Style = "Reference";
            paragraph.AddFormattedText(EANtitle + "Følgebrev", TextFormat.Bold);
            paragraph.AddLineBreak();

            // Add the print date field
            paragraph       = section.AddParagraph();
            paragraph.Style = "Reference";
            paragraph.AddText("I henhold til aftale fremsendes hermed:");

            // Create the item table
            this.table                     = section.AddTable();
            this.table.Style               = "Table";
            this.table.Borders.Color       = RescueTekniq.Doc.OrderForm_Dk.TableBorder;
            this.table.Borders.Width       = 0.25; //0.25
            this.table.Borders.Left.Width  = 0.5;
            this.table.Borders.Right.Width = 0.5;
            this.table.Rows.LeftIndent     = 0;
            this.table.Format.Font.Size    = "8pt";

            // Before you can add a row, you must define the columns
            Column column;

            column = this.table.AddColumn("2,25cm"); // - Item no
            column.Format.Alignment = ParagraphAlignment.Right;

            column = this.table.AddColumn(); //("6,50cm") ' - Item Name / Serial No
            column.Format.Alignment = ParagraphAlignment.Right;

            column = this.table.AddColumn("1,00cm"); // - Quantity
            column.Format.Alignment = ParagraphAlignment.Center;

            //column = Me.table.AddColumn("1,50cm") ' - Item Price
            //column.Format.Alignment = ParagraphAlignment.Right

            //column = Me.table.AddColumn("1,25cm") ' - Discount
            //column.Format.Alignment = ParagraphAlignment.Right

            //column = Me.table.AddColumn("1,50cm") ' - Sales price
            //column.Format.Alignment = ParagraphAlignment.Right

            //column = Me.table.AddColumn("2,00cm") ' - Line total
            //column.Format.Alignment = ParagraphAlignment.Right
            //'   Sum CM must be = 16 cm | 1+7,5+2+1+2+2,5
            //'

            // Create the header of the table
            Row row = default(Row);

            row = table.AddRow();
            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Shading.Color    = RescueTekniq.Doc.OrderForm_Dk.TableBlue;

            row.Cells[0].AddParagraph("Vare nr");
            row.Cells[0].Format.Alignment = ParagraphAlignment.Left;

            row.Cells[1].AddParagraph("Tekst");
            row.Cells[1].Format.Alignment = ParagraphAlignment.Left;

            row.Cells[2].AddParagraph("Antal");
            //.Cells(2).Format.Font.Bold = False
            row.Cells[2].Format.Alignment = ParagraphAlignment.Left;
            //.Cells(2).VerticalAlignment = VerticalAlignment.Bottom

            //.Cells(3).AddParagraph("Stk. pris ") 'DKK
            //.Cells(3).Format.Alignment = ParagraphAlignment.Left

            //.Cells(4).AddParagraph("Rabat") ' (%)Ambassadør - Reduktion
            //.Cells(4).Format.Alignment = ParagraphAlignment.Left

            //.Cells(5).AddParagraph("á pris")
            //.Cells(5).Format.Alignment = ParagraphAlignment.Left

            //.Cells(6).AddParagraph("i alt DKK")
            //.Cells(6).Format.Alignment = ParagraphAlignment.Right
            //'.Cells(6).VerticalAlignment = VerticalAlignment.Bottom
            //'.Cells(6).MergeDown = 1


            this.table.SetEdge(0, 0, 3, 1, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Creates the static parts of the invoice.
        /// </summary>
        private void CreatePage()
        {
            // Each MigraDoc document needs at least one section.
            Section section = this.document.AddSection();
            var     with_2  = section.PageSetup;

            //.HeaderDistance = "1cm"
            with_2.TopMargin = "4,5cm";

            with_2.BottomMargin   = "3,0cm";
            with_2.FooterDistance = "0,3cm";
            // Create footer


            // Put a logo in the header
            Image image = section.Headers.Primary.AddImage(Logo);

            image.Height             = "2.5cm";
            image.LockAspectRatio    = true;
            image.RelativeVertical   = RelativeVertical.Line;
            image.RelativeHorizontal = RelativeHorizontal.Margin;
            image.Top              = ShapePosition.Top;
            image.Left             = ShapePosition.Right;
            image.WrapFormat.Style = WrapStyle.Through;

            // Create the text frame for the address
            //section.Headers.Primary.AddParagraph()
            this.addressFrame = section.Headers.Primary.AddTextFrame(); //AddParagraph() 'section.AddTextFrame()
            //.Height = "3.0cm"
            this.addressFrame.Width = "8.0cm";
            this.addressFrame.Left  = ShapePosition.Left;
            this.addressFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.addressFrame.Top = "2.0cm";
            this.addressFrame.RelativeVertical = RelativeVertical.Page;


            // Create footer
            Paragraph paragraph = section.Footers.Primary.AddParagraph();
            var       with_6    = paragraph.Format;

            with_6.SpaceBefore         = "1cm";
            with_6.Font.Size           = 7;
            with_6.Borders.Color       = RescueTekniq.Doc.TilbudFolgemail_Dk.TableBorder;
            with_6.Borders.Width       = 0.25;
            with_6.Borders.Left.Width  = 0.5;
            with_6.Borders.Right.Width = 0.5;
            with_6.Alignment           = ParagraphAlignment.Center;
            paragraph.AddText(Company.name);
            paragraph.AddText(" · ");
            paragraph.AddText(Company.adresse);
            paragraph.AddText(" · ");
            paragraph.AddText(Company.zipcode);
            paragraph.AddText(" ");
            paragraph.AddText(Company.city);
            if (this.tilbud.Virksomhed.LandekodeID != 45)
            {
                paragraph.AddText(" · ");
                paragraph.AddText(Company.country);
            }
            paragraph.AddText(" · ");
            paragraph.AddText("CVR.nr. ");
            paragraph.AddText(Company.vatno);
            paragraph.AddText(" · ");
            if (this.tilbud.Virksomhed.LandekodeID != 45)
            {
                paragraph.AddText("Pho. ");
                paragraph.AddText(Company.int_phone);
            }
            else
            {
                paragraph.AddText("Tlf. ");
                paragraph.AddText(Company.phone);
            }
            paragraph.AddText(" · ");
            Hyperlink link = paragraph.AddHyperlink(string.Format("http://{0}", Company.link), HyperlinkType.Web);

            link.AddFormattedText(Company.link);


            var with_7 = section.Footers.Primary.AddParagraph();
            var with_8 = with_7.Format;

            with_8.Font.Size = 4;
            with_8.Alignment = ParagraphAlignment.Center;
            with_7.AddLineBreak();
            with_7.AddLineBreak();
            with_7.AddText("- TILBUD nr. " + tilbud.ID.ToString());
            with_7.AddText(" - side ");
            with_7.AddPageField();
            with_7.AddText(" af ");
            with_7.AddNumPagesField();
            with_7.AddText(" - ");

            // Create the text frame for the address
            this.headerFrame                    = section.AddTextFrame();
            this.headerFrame.Height             = "2.0cm";
            this.headerFrame.Width              = "4.0cm";
            this.headerFrame.Left               = ShapePosition.Right;
            this.headerFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            this.headerFrame.Top                = "4.5cm";
            this.headerFrame.RelativeVertical   = RelativeVertical.Page;
            // Add the print date field
            paragraph       = this.headerFrame.AddParagraph();
            paragraph.Style = "Reference";
            //.Format.Alignment = ParagraphAlignment.Right
            paragraph.AddFormattedText("TILBUD nr. " + tilbud.ID.ToString(), TextFormat.Bold);
            paragraph.AddLineBreak();
            paragraph.AddText(Company.city); //("Hillerød, ")
            paragraph.AddText(", ");
            paragraph.AddDateField("dd.MM.yyyy");
            paragraph.AddLineBreak();
            paragraph.AddText(System.Convert.ToString("/" + System.Convert.ToString(this.tilbud.Ansvarlig != "" ? this.tilbud.Ansvarlig : "LFU")));

            paragraph.AddLineBreak();
            paragraph.AddLineBreak();
            paragraph.AddText("Side ");
            paragraph.AddPageField();
            paragraph.AddText(" af ");
            paragraph.AddNumPagesField();


            //' Put sender in address frame
            //paragraph = Me.addressFrame.AddParagraph()
            //With paragraph
            //    .AddText("Heart2Start Aps · Gefionsvej 8 · 3400 Hillerød")
            //    .Format.Font.Name = "Times New Roman"
            //    .Format.Font.Size = 7
            //    .Format.SpaceAfter = 3
            //End With

            // Add the print date field
            //paragraph = section.AddParagraph()
            //With paragraph
            //    .Format.SpaceBefore = "5cm"
            //    .Style = "Reference"
            //    .AddFormattedText("TILBUD nr. " & tilbud.ID.ToString, TextFormat.Bold)
            //    .AddTab()
            //    .AddText("Hillerød, ")
            //    .AddDateField("dd.MM.yyyy")
            //    .Format.Font.Color = RGB(255, 0, 0)
            //End With

            // Add the print date field
            paragraph = section.AddParagraph();
            paragraph.Format.SpaceBefore = "3cm";
            paragraph.Style = "Reference";
            paragraph.AddFormattedText("Fremsendelse af tilbud", TextFormat.Bold);
            paragraph.AddLineBreak();
            // Add the print date field
            paragraph       = section.AddParagraph();
            paragraph.Style = "Reference";
            paragraph.AddText("I henhold til aftale fremsendes hermed tilbud på:");

            // Create the item table
            this.table                     = section.AddTable();
            this.table.Style               = "Table";
            this.table.Borders.Color       = RescueTekniq.Doc.TilbudFolgemail_Dk.TableBorder;
            this.table.Borders.Width       = 0.25;
            this.table.Borders.Left.Width  = 0.5;
            this.table.Borders.Right.Width = 0.5;
            this.table.Rows.LeftIndent     = 0;

            // Before you can add a row, you must define the columns
            Column column;

            column = this.table.AddColumn("1cm"); //1cm - Antal
            column.Format.Alignment = ParagraphAlignment.Center;

            column = this.table.AddColumn("7,75cm"); //3cm - Beskrivelse
            column.Format.Alignment = ParagraphAlignment.Right;

            column = this.table.AddColumn("1,75cm"); //3cm - Stk. pris DKK
            column.Format.Alignment = ParagraphAlignment.Right;

            column = this.table.AddColumn("1,75cm"); //3cm - Reduktion
            column.Format.Alignment = ParagraphAlignment.Right;

            column = this.table.AddColumn("1,75cm"); //3cm - á pris
            column.Format.Alignment = ParagraphAlignment.Right;

            column = this.table.AddColumn("2cm"); //3cm - i alt
            column.Format.Alignment = ParagraphAlignment.Right;
            //   1+(5*3) = 16 cm | 1+7,5+2+1+2+2,5

            // Create the header of the table
            Row row = default(Row);

            //row = table.AddRow()
            //With row
            //    .HeadingFormat = True
            //    .Format.Alignment = ParagraphAlignment.Center
            //    .Format.Font.Bold = True
            //    .Shading.Color = TableBlue
            //    .Cells(0).AddParagraph("Antal")
            //    .Cells(0).Format.Font.Bold = False
            //    .Cells(0).Format.Alignment = ParagraphAlignment.Left
            //    .Cells(0).VerticalAlignment = VerticalAlignment.Bottom
            //    .Cells(0).MergeDown = 1

            //    .Cells(1).AddParagraph("Beskrivelse")
            //    .Cells(1).Format.Alignment = ParagraphAlignment.Left
            //    .Cells(1).MergeRight = 3

            //    .Cells(5).AddParagraph("i alt")
            //    .Cells(5).Format.Alignment = ParagraphAlignment.Right 'Left
            //    .Cells(5).VerticalAlignment = VerticalAlignment.Bottom
            //    .Cells(5).MergeDown = 1
            //End With

            row = table.AddRow();
            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            row.Shading.Color    = RescueTekniq.Doc.TilbudFolgemail_Dk.TableBlue;

            row.Cells[0].AddParagraph("Antal");
            row.Cells[0].Format.Font.Bold  = false;
            row.Cells[0].Format.Alignment  = ParagraphAlignment.Left;
            row.Cells[0].VerticalAlignment = VerticalAlignment.Bottom;
            //.Cells(0).MergeDown = 1

            row.Cells[1].AddParagraph("Beskrivelse");
            row.Cells[1].Format.Alignment = ParagraphAlignment.Left;

            row.Cells[2].AddParagraph("Stk. pris "); //DKK
            row.Cells[2].Format.Alignment = ParagraphAlignment.Left;

            row.Cells[3].AddParagraph("Reduktion"); // (%)Ambassadør - Reduktion
            row.Cells[3].Format.Alignment = ParagraphAlignment.Left;

            row.Cells[4].AddParagraph("á pris");
            row.Cells[4].Format.Alignment = ParagraphAlignment.Left;

            row.Cells[5].AddParagraph("i alt");
            row.Cells[5].Format.Alignment  = ParagraphAlignment.Right; //Left
            row.Cells[5].VerticalAlignment = VerticalAlignment.Bottom;
            //.Cells(5).MergeDown = 1


            this.table.SetEdge(0, 0, 6, 1, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);
        }
Exemplo n.º 25
0
        public static void OutputPDF(string path, List <DesignatorGroup> groups, HeaderBlock header, string file, bool rtf = false)
        {
            Console.WriteLine("Generating " + file + "...");

            // document setup
            var doc = new Document();

            doc.DefaultPageSetup.PageFormat   = PageFormat.A4;
            doc.DefaultPageSetup.Orientation  = Orientation.Landscape;
            doc.DefaultPageSetup.TopMargin    = "1.5cm";
            doc.DefaultPageSetup.BottomMargin = "1.5cm";
            doc.DefaultPageSetup.LeftMargin   = "1.5cm";
            doc.DefaultPageSetup.RightMargin  = "1.5cm";
            doc.Styles["Normal"].Font.Name    = "Arial";

            var footer = new Paragraph();

            footer.AddTab();
            footer.AddPageField();
            footer.AddText(" of ");
            footer.AddNumPagesField();
            footer.Format.Alignment = ParagraphAlignment.Center;

            // generate content
            var section = doc.AddSection();

            section.Footers.Primary.Add(footer.Clone());
            section.Footers.EvenPage.Add(footer.Clone());
            PDFCreateHeader(ref section, header);
            var para  = section.AddParagraph();
            var table = PDFCreateTable(ref section);

            // BOM table
            int i = 1;

            foreach (DesignatorGroup g in groups)
            {
                // check for groups that are entire "no part"
                bool all_no_part = true;
                foreach (Component c in g.comp_list)
                {
                    if (!c.no_part)
                    {
                        all_no_part = false;
                    }
                }
                if (all_no_part)
                {
                    continue;
                }

                // group header row
                var row = table.AddRow();
                row.Shading.Color             = Colors.LightGray;
                row.Cells[0].MergeRight       = 6;
                row.Cells[0].Format.Alignment = ParagraphAlignment.Left;

                DefaultComp def = Component.FindDefaultComp(g.designator);
                if (def != null)
                {
                    var p = row.Cells[0].AddParagraph(def.long_name);
                    p.Format.Font.Bold = true;
                    if (def.has_default)
                    {
                        row.Cells[0].AddParagraph("All " + def.default_type + " unless otherwise stated");
                    }
                }
                else
                {
                    var p = row.Cells[0].AddParagraph(g.designator);
                    p.Format.Font.Bold = true;
                }

                foreach (Component c in g.comp_list)
                {
                    if (c.no_part)
                    {
                        continue;
                    }

                    row = table.AddRow();
                    row.Cells[0].AddParagraph(i++.ToString());
                    row.Cells[1].AddParagraph((c.count + 1).ToString());
                    row.Cells[2].AddParagraph(c.reference);
                    row.Cells[3].AddParagraph(c.value);

                    string temp = c.footprint_normalized;
                    if (c.code != null)
                    {
                        temp += ", " + c.code;
                    }
                    if (c.precision != null)
                    {
                        temp += ", " + c.precision;
                    }
                    row.Cells[4].AddParagraph(temp);
                    //row.Cells[4].AddParagraph(c.footprint_normalized);

                    row.Cells[5].AddParagraph(c.part_no);
                    row.Cells[6].AddParagraph(c.note);
                }
            }

            // generate PDF file
            if (!rtf)
            {
                var pdfRenderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);
                pdfRenderer.Document = doc;
                pdfRenderer.RenderDocument();
                pdfRenderer.PdfDocument.Save(file);
            }
            else
            {
                var rtfRenderer = new RtfDocumentRenderer();
                rtfRenderer.Render(doc, file, null);
            }
        }